Using end-arrow down or end-arrow up in a macro

G

Guest

I created a macro to gather a short list of data items for some numbers that
are in 3 different spreadsheets (all identical, just a different series of
numbers on each).

I started the macro by telling it to go to a hard location in the first
spreadsheet (where the list of numbers starts), then end-arrow down to the
last number, then over to the next column where I have a vlookup function.
Each day, the list on each spreadsheet may be shorter or longer, depending on
which numbers are chosen.

My macro unfortunately uses the same quantity of numbers on each spreadsheet
each time, remembering the number of rows down when first created.

How can I alter it so that it knows to stop at the last number in the list,
regardless of how many are in the list, and be able to do it again when the
list becomes shorter or longer?
 
G

Guest

'
Range("B2").Select
Application.Goto Reference:="R3C16"
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlUp).Select
Range("Q12").Select
Range(Selection, Selection.End(xlUp)).Select
Selection.Copy
Windows("Book1").Activate
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.End(xlDown).Select
Range("A11").Select
Windows("Cost Listing.xls").Activate
ActiveSheet.Next.Select
Range("B2").Select
Application.Goto Reference:="R3C16"
Range("P4").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlUp).Select
Range("Q10").Select
Range(Selection, Selection.End(xlUp)).Select
Selection.Copy
Windows("Book1").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.End(xlDown).Select
Range("A19").Select
Windows("Cost Listing.xls").Activate
ActiveSheet.Next.Select
Range("B2").Select
Application.Goto Reference:="R3C16"
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlUp).Select
Range("Q4").Select
Range(Selection, Selection.End(xlUp)).Select
Selection.Copy
Windows("Book1").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1:A20").Select
Selection.Style = "Currency"
Selection.NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top