Trying to make a variable cell reference

tbeynon1

New Member
Joined
Sep 16, 2015
Messages
15
Basically i want to find the last row used (With Data In) and then use that number in a cell reference for data i want to copy over from a different work sheet.
here is some of my code, I do realize that putting the x in the reference wont work but it shows what i want to achieve:

Code:
'Find the last Row with data in a Column
'In this example we are finding the last row of column A
Dim lastRow As Long
Dim x As Integer
With ActiveSheet
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
lastRow = x




'Moving the CSV file data to the right places on new sheet


'Moving Load no to column B
Sheets("CSV").Range("A1:Ax").Copy
Sheets("Sheet1").Activate
Range("B1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Try:
Code:
Sub tbeynon1()
    Application.ScreenUpdating = False
    Dim bottomA As Long
    bottomA = Sheets("CSV").Range("A" & Rows.Count).End(xlUp).Row
    Sheets("CSV").Range("A1:A" & bottomA).Copy Sheets("Sheet1").Range("B1")
    Application.ScreenUpdating = True
End Sub
This assumes that the last row with data is in the "CSV" sheet.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,598
Messages
6,125,748
Members
449,258
Latest member
hdfarid

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