VBA- Finding last populated cell in a column with blanks

JoeRooney

Board Regular
Joined
Nov 27, 2017
Messages
173
Office Version
  1. 365
Hi ,

Wondering if anyone could advise me on a more efficient wayof coping & pasting data between two sheets.

Below is my code

Sheets("SCF_File").Select
Range("G2:G10000").Select
Selection.Copy
Sheets("Running File").Select
Range("E" & Rows.Count).End(xlUp).Offset(1,0).PasteSpecial


The above code works fine and pastes into the next blank cellbut I do not like to be restricted by specific ranges.

I was using the below code to select my data but some cells hadblanks so that would not get all the data.

Range("E2").Select
Range(Selection,Selection.End(xlDown)).Select
Selection.Copy

My question is , Column A willnot have blanks, is it possible to go the last cell in columnG based on the last cell populated in cell A and copy up to G2?

I.e. Cell A500 is the last populated cell in column A ,could I copy range G2:G500 ,

Hope that makes sense.

Thanks,

 

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.
Try:
Rich (BB code):
Sub Test()

    Dim x  As Long
    
    With sheets("SCF_File")
        x = .Cells(.Rows.Count, 1).End(xlUp).Row - 1
        sheets("Running File").Cells(Rows.Count, 5).End(xlUp).Offset(1).Resize(x).Value = .Cells(2, 7).Resize(x).Value
    End With
        
End Sub
Numbers in blue are column index values where A = 1, B = 2... Z = 26 etc
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,021
Latest member
Mohamed Magdi Tawfiq Emam

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