View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
DoooWhat DoooWhat is offline
external usenet poster
 
Posts: 37
Default Pull user-specified rows from data set

I am having trouble manipulating some code I have used for a similar
purpose in the past. I have 2 drop-down boxes on my "Graphs" sheet.
The first one specifies the start date to analyze, the second box
specifies the end date. There are 2 corresponding cells (L10 and L11)
that indicate the position of the selection in the list. I can figure
out the exact row number that I need to look at in my source sheet
("Historical Balances") from these cells.

I need help changing this code so that it will pull only the selected
range of dates and paste them back to my "Graphs" sheet. The first
date in the list (on the "Historical Balances" sheet) is in cell A2
(and it will remain there indefinitely). The last date in the list
will move as I add more data. Here is the code I have so far:

Sub PasteDatesToGraph()

Dim FirstRow As Long
Dim LastRow As Long
Dim DestCell As Range
Dim RngToCopy As Range

With Worksheets("Historical Balances")
FirstRow = .Cells( A & row specified in cell L10 on the Graphs
sheet
LastRow = .Cells( A & row specified in cell L11 on the Graphs
sheet
Set RngToCopy = .Range( A & FirstRow : A & LastRow)
End With
With Worksheets("Graphs")
Set DestCell = Worksheets("Graphs").Range("N2")
End With
RngToCopy.Copy _
Destination:=DestCell

End Sub

Any help would be much appreciated. Thanks so much.

Kevin