Macro to read most recent row of data
Closed
jatwork
-
Apr 21, 2010 at 10:21 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Apr 21, 2010 at 05:39 PM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Apr 21, 2010 at 05:39 PM
Related:
- Macro to read most recent row of data
- Ps3 won't read disc - Guide
- Read news on kindle - Guide
- Saints row 2 cheats - Guide
- Tmobile data check - Guide
- Xbox 360 attempting to read media - Guide
5 responses
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Apr 21, 2010 at 10:43 AM
Apr 21, 2010 at 10:43 AM
You did not mention where the data needs to go on other sheet.
Assuming the on the last row, column A is always populated, and row is to be copied on the same row on other sheet then
Dim lMaxRows as long
lMaxRows = Cells(Rows.count, "A").end(xlup).row
sheets("Worksheet B").range(lMaxRows & ":" & lMaxRows ) = sheets("Worksheet A").range(lMaxRows & ":" & lMaxRows ).value
Assuming the on the last row, column A is always populated, and row is to be copied on the same row on other sheet then
Dim lMaxRows as long
lMaxRows = Cells(Rows.count, "A").end(xlup).row
sheets("Worksheet B").range(lMaxRows & ":" & lMaxRows ) = sheets("Worksheet A").range(lMaxRows & ":" & lMaxRows ).value
Thanks so much for the speedy answer rizvisa1. That code works, but as you pointed out I was a big vague - let me be more specific. Sheet A will have a new line added each month with 10 pieces (columns) of info in each row. Sheet B needs to be a summary of specific info from the newest month of Sheet A. I have 2 different scenario needs for Sheet B:
1. Info from Sheet A (ie row 20), columns A, C& E (20A, 20C & 20E) onto Sheet B row 20. Next month row references for both Sheet A & B would reference row 21
2. Info from Sheet A (ie row 20), columns A, C& E (20A, 20C & 20E) onto Sheet B row 1, but ALWAYS row 1, where Sheet B row 1 gets overwritten each month so as just to report on current month
Thanks :)
1. Info from Sheet A (ie row 20), columns A, C& E (20A, 20C & 20E) onto Sheet B row 20. Next month row references for both Sheet A & B would reference row 21
2. Info from Sheet A (ie row 20), columns A, C& E (20A, 20C & 20E) onto Sheet B row 1, but ALWAYS row 1, where Sheet B row 1 gets overwritten each month so as just to report on current month
Thanks :)
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Apr 21, 2010 at 12:37 PM
Apr 21, 2010 at 12:37 PM
Could you please upload a sample file on some shared site like https://authentification.site and post back here the link to allow better understanding of how it is now and how you foresee.
Thanks for your time, much appreciated. Here are the 2 samples I created just for illustration:
https://authentification.site/files/22058909/sample_1.xls
https://authentification.site/files/22058910/sample_2.xls
https://authentification.site/files/22058909/sample_1.xls
https://authentification.site/files/22058910/sample_2.xls
Didn't find the answer you are looking for?
Ask a question
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Apr 21, 2010 at 05:39 PM
Apr 21, 2010 at 05:39 PM
Dim lMaxRows As Long
lMaxRows = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("Summary").Range("D1") = Sheets("Sheet1").Range("A" & lMaxRows).Value
Sheets("Summary").Range("A4") = Sheets("Sheet1").Range("D" & lMaxRows).Value
lMaxRows = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("Summary").Range("D1") = Sheets("Sheet1").Range("A" & lMaxRows).Value
Sheets("Summary").Range("A4") = Sheets("Sheet1").Range("D" & lMaxRows).Value