PDA

View Full Version : on each page, highlight the first cell on column A



uktous
07-19-2013, 08:50 AM
Hi,

Could you please write the macro which can perform the following function?

on each page, highlight the first cell on column A

Thanks

p45cal
07-19-2013, 09:05 AM
Sub ggew()
For Each sht In ActiveWorkbook.Sheets
sht.Range("A1").Interior.ColorIndex = 6
Next sht
End Sub

uktous
07-19-2013, 09:48 PM
Sub ggew()
For Each sht In ActiveWorkbook.Sheets
sht.Range("A1").Interior.ColorIndex = 6
Next sht
End Sub


sorry, I did not provide enough detail...

The macro that I wish is different from you shown.

What I wish is ...

Suppose on sheet1, there are 10 pages.
Then the macro can highlight the first cell on column A , each of those 10 pages.
Ingore other sheets.

Could you please re-write the macro?

Thanks

p45cal
07-20-2013, 01:43 AM
the following makes a few assumptions so might, might not, work for you:
Sub blah()
For Each hpb In ActiveSheet.HPageBreaks
hpb.Location.Interior.ColorIndex = 6
Next hpb
End Sub

uktous
07-20-2013, 04:16 AM
the following makes a few assumptions so might, might not, work for you:
Sub blah()
For Each hpb In ActiveSheet.HPageBreaks
hpb.Location.Interior.ColorIndex = 6
Next hpb
End Sub


not work...

could you please tell me the assumption?

mancubus
07-20-2013, 04:37 AM
hi,

posting the file here and showing the expected result of the macro in that file can help assuming your requirements. :)

p45cal
07-20-2013, 06:49 AM
not work...

could you please tell me the assumption?
Oh, lots.. could I second what mancubus said.

uktous
07-20-2013, 11:02 PM
Oh, lots.. could I second what mancubus said.

I attached the file.

Please note that on column A the data are random, and so there is no pattern.

p45cal
07-21-2013, 01:42 AM
Except for the first page, my snippet worked on your file. To get the first page's highlight I added a line:Sub blah()
With ActiveSheet
.UsedRange.Cells(1).Interior.ColorIndex = 6
For Each hpb In .HPageBreaks
hpb.Location.Interior.ColorIndex = 6
Next hpb
End With
End Sub