Forum Discussion
Convert colored filled cells to numbers
- Jan 15, 2020My pleasure
The steps you have to perform are the following
1. Open my file (the one which contains the macro)
2. Open the VBA editor (Alt+F11)
3. Navigate to sheet1
4. copy the entire code you see
5. Open your file
6. Open the VBA editor (Alt+F11)
7. Select the sheet in which you want the code to run (yes, the code will only run in this sheet)
8. paste the code into the VBA editor
9. test, save and hopefully be happy with it 🙂
Open the VBA editor with Alt+F11
The VBA code is in Sheet 1
The column with the color is defined here:
If Cells(x, 1).Interior.ColorIndex = 3 Then Cells(x, 1).Offset(0, 1) = 1
Becasue A is the first column, there is a 1. If you want to change to column C, just change this number to 3
The column where the number is pasted is defined here
If Cells(x, 1).Interior.ColorIndex = 3 Then Cells(x, 1).Offset(0, 1) = 1
It's defined as an offset of 1 to the right of the colored cell. but you could also offset it by a different number.
Just play around with it to see what happens when you change these numbers.
- PascalKTeamJan 22, 2020Iron ContributorOK good.
Yes i can but we should not use this topic
You can send a private message to me if you want - kevinduqueJan 22, 2020Brass Contributor
PascalKTeam its all good now thank you i restarfted my laptop and it worked thank you... can you help me with my other qeuries?
- PascalKTeamJan 22, 2020Iron ContributorI would need more information to find out the reason for the problem...
Can you post the file? - kevinduqueJan 22, 2020Brass Contributor
PascalKTeam yes so basically I have two diff file name but the same source both file only have two sheets so the first one just perfectly working but the other one for some reason its not running...
- PascalKTeamJan 22, 2020Iron ContributorHave you adjusted the code for your columns as explained above?
- kevinduqueJan 22, 2020Brass Contributor
PascalKTeam Hi -
I did use the code to diff file woudl oyu know why its not working? theres no error message but for some reason its not working
- kevinduqueJan 15, 2020Brass Contributor
PascalKTeam Thank you so much it works perfectly
- PascalKTeamJan 15, 2020Iron ContributorMy pleasure
The steps you have to perform are the following
1. Open my file (the one which contains the macro)
2. Open the VBA editor (Alt+F11)
3. Navigate to sheet1
4. copy the entire code you see
5. Open your file
6. Open the VBA editor (Alt+F11)
7. Select the sheet in which you want the code to run (yes, the code will only run in this sheet)
8. paste the code into the VBA editor
9. test, save and hopefully be happy with it 🙂 - kevinduqueJan 15, 2020Brass Contributorlast question and thank you you have been very helpful - id like to assign this MACRO to a sheet in my workbook what is the command for that? that is this macro will only run in that particular sheet?