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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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,217,474
Messages
6,136,860
Members
450,028
Latest member
CHlEFS47

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