this may or may not have been asked yet.
I am trying to copy a Range of Cells from one worksheet to another using a macro. the problem I am having is that the Range I want to copy varies drastically every time the macro is run.
For example I wan to Copy Range("A2:P64") on first run, then when i run the data again the start of the Range is still A2, but the end of the range may be P25 or p90000. It is always Column P and (x variable) Row.
I have tried things like this:
Dim past As Worksheet
Dim countHist As String
Dim view As Worksheet
Dim countView As String
Set view = ThisWorkbook.Worksheets("BlueSteel Errors")
Set past = ThisWorkbook.Worksheets("Historical")
countView = view.Cells(Rows.Count, "A").End(xlUp).Row
countHist = past.Cells(Rows.Count, "A").End(xlUp).Row
MsgBox ("P" & countView) ' This currently gives the count of 53, so output is P53
view.Range("A2:P & countView").Select ' THIS IS THE PROBLEM LINE.. should look
'should resemble view.Range("A2:P53").Select
'EVERYTHING ELSE APPEARS TO WORK
Selection.Copy
past.Select
Range("A" & countHist).Select
ActiveSheet.Paste
I cannot find a way to determine the last line that text exists, and then append that number to the end of the Range field so i can Select and append to the other sheet.. I only need the data from A2 - Px not All of the excess fields beyond P. Perhaps I need to copy then delete that.