Forum

VBA; If cell is col...
 
Notifications
Clear all

VBA; If cell is colored then column value

2 Posts
2 Users
0 Reactions
53 Views
(@darkwing1711)
Posts: 31
Trusted Member
Topic starter
 

Hi all!

I need help with a VBA macro.  What I need is: If a cell is (color) blue, then pull value from a different column on the same row.  (I am using a table.)

Column1 Column2 Column3 Column4 Column5 Column6 Column7
(Color Blue)           Test1
            Test2
            Test3
(Color Blue)           Test4
            Test5

result looking for

Column1 Column2 Column3 Column4 Column5 Column6 Column7
Test1           Test1
            Test2
            Test3
Test4           Test4
            Test5

So far I got (Below is just an example and not sure if it's correct)

'Declare Sheet 1

Dim sh1 as Worksheet

Set sh1=Sheet1

 

'Delcare Sheet 1 column 1

Dim sh1c1 as Range

Set sh1c1=sh1.ListObjects("Table1").ListColumns(1).DataBodyRange

 

'Declare sheet 1 column 6

Dim sh1c6 as Range

Set sh1c6=sh1.ListObjects("Table1").ListColumns(6).DataBodyRange

 

'If cell is blue then column 6

If sh1c1.Interior.Color=RGB(0,112,192) then sh1c6.value

End If

 
Posted : 28/10/2020 1:16 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Kenneth,

Can you please attach your actual workbook otherwise any code we write will need to be modified to suit your real workbook environment.

Don't forget t click on Start Upload after selecting your file.

Regards

Phil

 
Posted : 28/10/2020 6:17 pm
Share: