LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Range question


Hi,

I want to find and select portions of a large excel spreadsheet. Onc
I determine the range, I want to select it, copy it, and paste it t
another worksheet, then find the next range. I 've make some headway
but I need help programatically selecting a range for the cut/past
operation. Below is some of my code. I need to use variable to choos
starting and ending cells to create my range. This is where I need hel
or ideas.

Dim myfile As String
Dim stopstring As String
Dim StartAddress As String
Dim EndAddress As String
Dim wsSource As Worksheet, wsDestination As Worksheet, wsSummary A
Worksheet
Dim Rng As Range, Rng1 As Range

Set wsDestination = ActiveSheet
'myfile = Application.GetOpenFilename

'open workbook, and get handle on first worksheet
Set wsSource = Workbooks.Open("C:\testdata.xls").Sheets(1)
'Set wsSource = Workbooks.Open(myfile).Sheets(1)

'copy a chunk, including formats
'wsSource.Range("A1:C60").Copy wsDestination.Range("A1")

'look for the word widgets
Set Rng = Range("A1:C60").Find(What:="firstWidget", lookat:=xlPart
LookIn:=xlValues)
StartAddress = ActiveCell.Address 'First valid row

stopstring = "" 'string that determines an invalid row (empty)

Do While ActiveCell.Value < stopstring
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell.Offset(-1, 0).Select
EndAddress = ActiveCell.Address 'last valid row

'copy selection to a temp worksheet where I union all the copy/paste
selections
wsDestination.Range(StartAddress:EndAddress).Cop
wsSummary.Range("A1")
'close workbook
wsSource.Parent.Close (False)

End Sub



Thanks for any help

--
mnewna
-----------------------------------------------------------------------
mnewnam's Profile: http://www.excelforum.com/member.php...fo&userid=1584
View this thread: http://www.excelforum.com/showthread.php?threadid=27333

 
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
Range question Jock Excel Worksheet Functions 3 March 19th 08 04:36 PM
Range Question N.F[_2_] Excel Discussion (Misc queries) 5 July 28th 07 01:05 AM
Range question in VB rohnds Excel Programming 3 July 14th 04 09:51 AM
If Range.Name question Otto Moehrbach[_5_] Excel Programming 8 November 30th 03 11:05 PM
Range.Formula and Range question using Excel Automation [email protected] Excel Programming 0 September 19th 03 04:53 AM


All times are GMT +1. The time now is 03:17 AM.

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"