Help me out on VBA code

dhkdwk7198

New Member
Joined
Aug 23, 2021
Messages
3
Platform
  1. Windows
Hi all,

I want to extract x-y coordinates of colored cells with specific value inside. Let's say there is cells filled with "A" and they are colored either red or green.
If I want to extract x-y coordinates for cells with "A" and green, what will be the VBA code?

Hope someone can help me on this!!

Thank you in advance.
 

Attachments

  • 제목 없음.png
    제목 없음.png
    6.7 KB · Views: 9

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I may not be able to follow up, but some questions...

x-y coordinates with respect to what (application, screen, A1 top-left)? And in what measurement (pixels, points)?
 
Upvote 0
I may not be able to follow up, but some questions...

x-y coordinates with respect to what (application, screen, A1 top-left)? And in what measurement (pixels, points)?
Thank you for fast response. I am looking for coordinates 1,1(A1), 2,1(B2), 3,1(B3), 1,2(A2), 2,2(B2), 3,1(B3) and so on.
 
Upvote 0
I may not be able to follow up, but some questions...

x-y coordinates with respect to what (application, screen, A1 top-left)? And in what measurement (pixels, points)?
Sorry there was typo. I am looking for coordinates 1,1(A1), 2,1(B1), 3,1(C1), 1,2(A2), 2,2(B2), 3,2(C2) and so on.
 
Upvote 0
Range("C2").Row will give the row number (2)
Range("C2").Column will give the column number (3)

Actually .Row and .Column will give top and left cell of any range respectively.

You can check for the condition like (not an actual code):

VBA Code:
If Range.Value = "A" and Range.Interior.Color = ColorCode then
    ' What to do
End If

Above Range.Value = "A" would be case sensitive.

You can get the color codes by selecting on of the colored cells and in Immediate window:
? ActiveCell.Interior.Color
or
? Selection.Interior.Color

? is the same as debug.print
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,046
Members
449,063
Latest member
ak94

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top