Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
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

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Pull user-specified rows from data set

Maybe...

Sub PasteDatesToGraph()

Dim FirstCell As Range 'changed!
Dim LastCell As Range 'this, too!
Dim DestCell As Range
Dim RngToCopy As Range

With Worksheets("Historical Balances")
set Firstcell = .Range("A" & worksheets("graphs").range("L10").value)
set LastCell = .range("A" & worksheets("graphs").range("L11").value)
Set RngToCopy = .Range(firstcell, lastcell)
End With
With Worksheets("Graphs")
Set DestCell = Worksheets("Graphs").Range("N2")
End With
RngToCopy.Copy _
Destination:=DestCell

End Sub

(Your code looked easier to understand than the words <vbg.)



DoooWhat wrote:

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


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Pull user-specified rows from data set

Sorry Dave, I know I didn't do the best job of explaining my problem.
However, you seem to have a handle on what I'm trying to do. The
macro gets stuck on the FirstRow part when I try to run it.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Pull user-specified rows from data set

What's in these cells?

worksheets("graphs").range("L10")
worksheets("graphs").range("L11")

Since you're using that to find the firstcell and lastcell, they had better
contain numbers--and so that A# becomes a valid address.



DoooWhat wrote:

Sorry Dave, I know I didn't do the best job of explaining my problem.
However, you seem to have a handle on what I'm trying to do. The
macro gets stuck on the FirstRow part when I try to run it.


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Pull user-specified rows from data set

There are formulas in these cells. The drop down boxes are linked to
cells L1 and L2 respectively.

Here are the formulas in cells L10 and L11:

L10: =L1+1
L11: =L2+1

I don't want to pick up the title row from the "Historical Balances"
page. That is the reason for the formulas.

The first date I have on the "Historical Balances" sheet is October
16, 2006. It is in cell A2. The drop down boxes are linked to
'Historical Balances'!A2:A5000.




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Pull user-specified rows from data set

You're not picking up the formula. You're picking up the values.

What are the values?

And if you changed the code, post back with your current code.

(It worked ok for me--with nice numbers in those two cells.)

DoooWhat wrote:

There are formulas in these cells. The drop down boxes are linked to
cells L1 and L2 respectively.

Here are the formulas in cells L10 and L11:

L10: =L1+1
L11: =L2+1

I don't want to pick up the title row from the "Historical Balances"
page. That is the reason for the formulas.

The first date I have on the "Historical Balances" sheet is October
16, 2006. It is in cell A2. The drop down boxes are linked to
'Historical Balances'!A2:A5000.


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Pull user-specified rows from data set

I finally got it to work. Sorry about the wild goose chase. I didn't
type "Set" before FirstCell and LastCell. That's what made it fail.

Thanks so much for your help. You rock.

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Pull user-specified rows from data set

And sorry about posting the new thread. I didn't realize that the
active older topics showed up on the right. I thought my new posts on
this one would get buried.

Thanks again.

Kevin

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I pull data from multiple user workbooks into one? Stuart Peters Excel Discussion (Misc queries) 4 April 8th 06 11:29 AM
pull data for a company with data in diff cells multiple wrkshts kcoachbiggs Excel Worksheet Functions 0 March 8th 06 09:24 PM
Pull data from yyyymmmmdd.xls Mike Punko Excel Worksheet Functions 1 October 3rd 05 08:31 PM
Links pull wrong line when rows are added nifferearly Excel Discussion (Misc queries) 1 June 3rd 05 10:41 PM
how to format pull down rows pjh Excel Worksheet Functions 1 November 8th 04 07:01 PM


All times are GMT +1. The time now is 09:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"