Last Row range

ToniB

New Member
Joined
Jan 5, 2019
Messages
6
Hi guys,
I hope you can help me with this. I am trying to select a range on varios sheets from cell A5 to the "last row" (in column A) and have "SPL" fill in. If I just select A5 it works, but when I try the range it does not. I hope you can help me! Here is the code below - I highlighted the row that is not working.


ws.Select
'Add 'TRNS' & 'ENDTRNS' to Col A
ws.Range("A4").Value = "TRNS" 'This adds 'TRNS' to A4
'#### This changes all of column A to 'TRNS' ####################
' intRowCount = Range("A4").CurrentRegion.Rows.Count + 3
' For i = 1 To intRowCount
' ActiveCell.Value = "TRNS"
' ActiveCell.Offset(1, 0).Select
' Next i
'################################################################
lr = Range("A" & Rows.Count).End(xlUp).Row
ws.Range("A5" & lr).Value = "SPL"
ws.Range("A" & lr).Offset(1, 0).Value = "ENDTRNS"


Thank you!
ToniB
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi guys,
I hope you can help me with this. I am trying to select a range on varios sheets from cell A5 to the "last row" (in column A) and have "SPL" fill in. If I just select A5 it works, but when I try the range it does not. I hope you can help me! Here is the code below - I highlighted the row that is not working.


ws.Select
'Add 'TRNS' & 'ENDTRNS' to Col A
ws.Range("A4").Value = "TRNS" 'This adds 'TRNS' to A4
'#### This changes all of column A to 'TRNS' ####################
' intRowCount = Range("A4").CurrentRegion.Rows.Count + 3
' For i = 1 To intRowCount
' ActiveCell.Value = "TRNS"
' ActiveCell.Offset(1, 0).Select
' Next i
'################################################################
lr = Range("A" & Rows.Count).End(xlUp).Row
ws.Range("A5" & lr).Value = "SPL"
ws.Range("A" & lr).Offset(1, 0).Value = "ENDTRNS"
You have not specified the range correctly. Try it this way...

ws.Range("A5:A" & lr).Value = "SPL"
 
Upvote 0

Forum statistics

Threads
1,216,082
Messages
6,128,713
Members
449,464
Latest member
againofsoul

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top