greykitten
Member
Hello Forum,
I'm very new to VBA and struggling with how I alter a macro to apply formatting when the number of rows changes from month to month. I used the macro recorder on a very simple example and I found the following snippet below to find the last row. But I'm not following where I add it to the code so that the macro works when the number of rows change.
Would it help to add this to the range?
In the example attached, the InitialTest tab has the macro applied to it without adding additional rows. On the FailedTest tab, I added 40 additional rows to test whether the macro would determine the total number of rows and adjust the range correctly to format all of the rows. The macro stopped at row 15 which is the number of rows in the RawData tab. Can someone please help me figure out how to adjust this macro so that it can handle varying numbers of rows? Thank you very much in advance for your help.
Thanks again,
greykitten
I'm very new to VBA and struggling with how I alter a macro to apply formatting when the number of rows changes from month to month. I used the macro recorder on a very simple example and I found the following snippet below to find the last row. But I'm not following where I add it to the code so that the macro works when the number of rows change.
Code:
Dim lRow As Long
lRow = Cells(Rows.Count, 1).End(xlUp).Row
Would it help to add this to the range?
Code:
Dim DataRange As Range
Set DataRange = Range("A1:AR" & lRow)
In the example attached, the InitialTest tab has the macro applied to it without adding additional rows. On the FailedTest tab, I added 40 additional rows to test whether the macro would determine the total number of rows and adjust the range correctly to format all of the rows. The macro stopped at row 15 which is the number of rows in the RawData tab. Can someone please help me figure out how to adjust this macro so that it can handle varying numbers of rows? Thank you very much in advance for your help.
Thanks again,
greykitten