Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple looping question


I have a spreadsheet from A2 to Z1500 and want to find the word "orde
form" which then has a number after it. The word "order form" is in
various locations all over the spreadsheet with different numbers
after each "order form".

I want to loop thru the entire spreadsheet and copy and paste eac
instance of "order form"and its unique number to sheet 2 starting at A
on down

--
ligh
-----------------------------------------------------------------------
light's Profile: http://www.excelforum.com/member.php...nfo&userid=722
View this thread: http://www.excelforum.com/showthread.php?threadid=39611

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Simple looping question

This should be close to what you want

Sub FindOrder()
Dim wksCopy As Worksheet
Dim wksPaste As Worksheet
Dim rngCopy As Range
Dim rngPaste As Range
Dim rngCurrent As Range
Dim rngFirst As Range

Set wksCopy = Sheets("Sheet1")
Set wksPaste = Sheets("Sheet2")
Set rngCopy = wksCopy.Range("A1:Z1500")
Set rngPaste = wksPaste.Range("A2")

Set rngCurrent = rngCopy.Find("Order Form")
If rngCurrent Is Nothing Then
MsgBox "No Order Forms Found"
Else
Set rngFirst = rngCurrent
Do
rngCurrent.Copy rngPaste
rngCurrent.Offset(0, 1).Copy rngPaste.Offset(0, 1)
Set rngPaste = rngPaste.Offset(1, 0)
Set rngCurrent = rngCopy.FindNext(rngCurrent)
Loop Until rngCurrent.Address = rngFirst.Address
End If
End Sub

--
HTH...

Jim Thomlinson


"light" wrote:


I have a spreadsheet from A2 to Z1500 and want to find the word "order
form" which then has a number after it. The word "order form" is in
various locations all over the spreadsheet with different numbers
after each "order form".

I want to loop thru the entire spreadsheet and copy and paste each
instance of "order form"and its unique number to sheet 2 starting at A2
on down.


--
light
------------------------------------------------------------------------
light's Profile: http://www.excelforum.com/member.php...fo&userid=7228
View this thread: http://www.excelforum.com/showthread...hreadid=396116


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple looping question


Jim

Thank-You very much. I notice the macro is reading accross by rows. I
would like it to read down by columns. Tried changing the offset but
then it has trouble with blank cells. How do I do this adjustment?


--
light
------------------------------------------------------------------------
light's Profile: http://www.excelforum.com/member.php...fo&userid=7228
View this thread: http://www.excelforum.com/showthread...hreadid=396116

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
IF formula-simple question; simple operator Rich D Excel Discussion (Misc queries) 4 December 6th 07 03:36 PM
Simple Simple Excel usage question BookerW Excel Discussion (Misc queries) 1 June 23rd 05 10:06 PM
looping question luke New Users to Excel 4 June 3rd 05 01:19 PM
Simple Array Looping Nikky Excel Programming 2 April 20th 05 10:38 PM
Looping question Rune_Daub[_8_] Excel Programming 1 November 8th 03 04:06 PM


All times are GMT +1. The time now is 12:55 PM.

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"