• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Perform macro functions on changing number of rows

Chris Turner

New Member
I recorded a macro for updating and formatting a spreadsheet. I run an update on this spreadsheet everyday. Currently, I have to change the row values in the recorded macro to match the number of rows in the daily data download from an ERP database. I would like to have the macro perform the operations down to the last row to match values in Column D which has time values. I have tried to change the macro but with little success. Any help would be appreciated. I have attached a sample to show how I receive the data download before the macro is activated.
 

Attachments

  • Workcenter-Sample.xlsm
    17.2 KB · Views: 5
Respecting TBTO rule, no need to know how many rows
just working directly with objects using for example
a For Each loop (a must see in VBA inner help) …

Anyway, as a beginner starter :​
Code:
Sub Demo0()
    With Sheet1.UsedRange.Rows
        MsgBox .Count, vbInformation, "  Number of rows :"
    End With
End Sub
Do you like it ? So thanks to click on bottom right Like !
 
Hi Marc L, thanks for the reply. I do not know what you mean by TBTO rule. Also, as for the code you provided, where would I add it into the current recorded macro?
 
Think, But Think Object !

I have to change the row values
As your code seems to not match with the worksheet
even if I select some rows
(errors at different codelines, is it really a "before" worksheet ?)
so replace the « row values » by the Count value,
you can use a variable to store this value …
 
Thanks for your help. I realized that I was asking one thing and the sample spreadsheet was indicating another. I finally figured out how to solve the problem and appreciate your help. I spurred me on to find the solution.
 
Back
Top