LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default data selection and copying

I'm new at this so I'm not sure of the validity of my question. I'm
trying to import data from a standardized format. The problem is that
the number of rows will vary depending on the set of data. So I need
some code that will take a selection starting from "Operating
Expenses" to the last expense (always 2 cells above "Total Operating
Expenses"). This is what I've got so far:

Sub CommandButton1_Click()
Sheets("Cash Flow").Select
ActiveSheet.Range("A1").Select
Do
ActiveCell.Offset(1, 0).Select
Loop Until ActiveCell.Offset(1, 0).Value = "Operating Expenses"
Set TopCell = Cells(ActiveCell.Row, ActiveCell.Column)
Do
ActiveCell.Offset(1, 0).Select
Loop Until ActiveCell.Offset(1, 0).Value = "Total Operating Expenses"
ActiveCell.Offset(-1, 0).Select
Set BottomCell = Cells(ActiveCell.Row, ActiveCell.Column)

Range(TopCell, BottomCell).Select
Selection.Copy
Sheets("Sheet1").Select
Selection.Paste
End Sub

I keep getting the "selection method of range class failed" error for
the "Range(TopCell, BottomCell).Select"

Any suggestions?

Thanks!

 
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
data selection Desmond Excel Discussion (Misc queries) 1 March 2nd 07 03:36 AM
Copying Excel 2003 Selection into Outlook 2003 HTML E-Mail Message [email protected] Excel Discussion (Misc queries) 0 July 10th 06 03:07 PM
Moving a Selection of data??? Lime Excel Worksheet Functions 3 December 17th 05 06:55 PM
Getting error "selection is too large" when copying data Tootie Excel Discussion (Misc queries) 1 October 6th 05 12:19 AM
Getting error "selection is too large" when copying data Tootie Excel Discussion (Misc queries) 0 October 5th 05 08:42 PM


All times are GMT +1. The time now is 11:19 PM.

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

About Us

"It's about Microsoft Excel"