Home |
Search |
Today's Posts |
#13
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Most welcome.
"Bruce" wrote: JMB; Thanks. I would have never figured this out. Bruce -- VBA Rookie "JMB" wrote: Try this: Sub test() Dim rngCell1 As Range Dim rngCell2 As Range Set rngCell1 = Cells(Rows.Count, 2).End(xlUp) Set rngCell2 = Cells(Rows.Count, 18).End(xlUp) If rngCell1.Value < rngCell2.Value Then rngCell2.Interior.ColorIndex = 36 Else: rngCell2.Interior.ColorIndex = xlNone End If End Sub "Bruce" wrote: JMB; You are awsome. Thanks. You saved me hours of trial and error. If I wasn't such an old rookie my eyesight would be better and I could have saved you the last response. A further question, if you don't mind. Let's assume I want to do verify a calculation on the last row and Highlight the cell if there is an error. Example: If "Col B,last row" not = "Col R, last row" then highlight "Col R, last row". How would I code this in VBA? Thanks again for your help. Bruce -- VBA Rookie "JMB" wrote: x1up : the 1 s/b an l (lowercase letter L) "Bruce" wrote: JMB; Below is my copied routine. The With statement is highlighted in the debugger. The spreadsheet has 2 lines of title, 2 blank lines, 1 more title line, a blank line, and then continuous detail, a blank line or two, and then a final line. It is possible to have multiple "breaks " of blank lines throughout the report. Sub XX() ' ' XX Macro ' ' With ActiveSheet With .Cells(.Rows.Count, 1).End(x1up).Resize(1, 8) .Font.Bold = True End With End With Range("A6").Select End Sub -- VBA Rookie "JMB" wrote: To work with the activesheet - you can qualify it Sub test() With ActiveSheet With .Cells(.Rows.Count, 1).End(xlUp).Resize(1, 8) .Font.Bold = True End With End With End Sub or just use (the post will likely get wrapped funny - there is three lines in the following macro) and VBA will assume the activesheet Sub test() Cells(Rows.Count, 1).End(xlUp).Resize(1, 8).Font.Bold = True End Sub You would have to copy the code from your macro into a post before I can try to figure out why it is not working (and the error description and which line it breaks on would also help) - it runs okay for me. Note there is a period in front of Cells and Font for the macro(s) that have a With statement. "Bruce" wrote: JMB; I have tried this code and I get an error and it goes into debug mode. I have typed the macro exactly as you have it. I did change Sheet2 to Sheet1. As a side note, how would I default this to the active sheet? Thanks - Bruce -- VBA Rookie "JMB" wrote: This should find the last cell in Col A that has an entry. Then changes the font in column A-H to bold for that row. Modify to use whatever formatting you wanted. Sub test() With Worksheets("Sheet2") With .Cells(.Rows.Count, 1).End(xlUp).Resize(1, 8) .Font.Bold = True End With End With End Sub "Calle" wrote: Hi! Is it possible for a macro to format the last row from say A-H in a worksheet. I can't do this manually since the length of the worksheet changes from time to time. Regards Calle |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to format a sheet | Excel Programming | |||
How do I format a sheet using a copy macro? | Excel Programming | |||
can I clean old excel data format with macro on funny spread sheet | Excel Programming | |||
How do I copy a print format from sheet to sheet in excel ? | Excel Discussion (Misc queries) | |||
Can a macro format a hidden sheet? | Excel Discussion (Misc queries) |