VBA - pasting data in the last cell of a column

tanyaleblanc

Board Regular
Joined
Mar 16, 2019
Messages
145
Hi, I'm trying to paste data from cell L1 (the word "Rental") to the last cell in column G, but it's pasting in the wrong cell, it should paste in cell G40 as that is the last blank cell, but it's pasting in cell G6988 and then I want it to copy the word "Rental" to the last cell that has data in column E

Code:
lrownew = Cells(Rows.Count, "E").End(xlUp).Row + 1    Range("E" & lrownew).PasteSpecial Paste:=xlPasteValues
    lastrow = Cells(Rows.Count, "G").End(xlUp).Row
    Range("L1").Select
    Selection.Copy
    lrownew = Cells(Rows.Count, "G").End(xlUp).Row + 1
    Range("G" & lRow).PasteSpecial Paste:=xlPasteValues
    Range("g:g" & lRow).SpecialCells(xlCellTypeVisible) = "Rental"
 
Last edited:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
How about
Code:
range("G"&rows.Count).End(xlUp).Offset(1).Value="Rental"
 
Upvote 0
I've changed the code to the above and it now pastes the word "Rental" in cell G40 like it's supposed to but how do I copy it to the last row using column E

Code:
Sub Admin_Fee()Dim fd As Office.FileDialog
Dim lRow As Long
Dim wb1 As Workbook, wb2 As Workbook
Dim sh As Worksheet
Dim lrownew As Long
If AutoFilterMode = True And FilterMode = True Then ActiveSheet.ShowAllData


    
Set fd = Application.FileDialog(msoFileDialogFilePicker)


    Windows("Admin Fee1.xls").Activate
    Sheets("Active").Select
    lastrow = Cells(Rows.Count, "G").End(xlUp).Row
    Range("L1").Select
    Selection.Copy
    lrownew = Cells(Rows.Count, "G").End(xlUp).Row + 1
    Range("G" & Rows.Count).End(xlUp).Offset(1).Value = "Rental"
End Sub
 
Upvote 0
How about
Code:
Range(Range("G" & Rows.Count).End(xlUp).Offset(1), Range("E" & Rows.Count).End(xlUp).Offset(, 2)).Value = "Rental"
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,271
Members
452,628
Latest member
dd2

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