Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Do until loop

Hi,

I need the following to code to loop, but each time pasting one row further
down on Sheet 2 until the Control Find function finds "Ele NonRec END".



Cells.Find(What:="ele nonrec", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Selection.Copy
Sheets("Sheet2").Select
Range("A2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="record sent", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("I2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="global", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("X2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="o", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False) _
.Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("AD2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select

Please help!! Thank you in advance.

John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Do until loop


It appears that you are doing a lot of unnecessary work here. Selections
are NOT needed. You should be able to do this from anywhere in the workbook
without any selections.
It appears that you are looking for more than one instance of each of the
three text values??? Then, do you want to copy to the next available row on
the desired destination sheet?
If so, there is an excellent example of FINDNEXT in the vba help index. Or,
give exact details of what you are attempting.

--
Don Guillett
SalesAid Software

"JohnP" wrote in message
...
Hi,

I need the following to code to loop, but each time pasting one row
further
down on Sheet 2 until the Control Find function finds "Ele NonRec END".



Cells.Find(What:="ele nonrec", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Selection.Copy
Sheets("Sheet2").Select
Range("A2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="record sent", After:=ActiveCell, LookIn:=xlFormulas,
_
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("I2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="global", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("X2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="o", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False) _
.Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("AD2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select

Please help!! Thank you in advance.

John



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default Do until loop

Make a backup of your spreadsheet and in the backup test this code:

' - START OF CODE -
Option Explicit

Private Function lookForNext(s As String, r As Range, ws As Worksheet)
As Range
Set lookForNext = ws.Cells.Find(What:=s, After:=r,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False)
End Function

Public Sub DoUntilJohnP()

On Error GoTo DOUJP_ERR

Dim wb As Workbook
Dim wsOld As Worksheet, wsNew As Worksheet
Dim rOld As Range, rNew As Range

Set wb = ActiveWorkbook
Set wsOld = wb.ActiveSheet
Set wsNew = wb.Sheets("Sheet2")

Set rOld = wsOld.Range("A1")
Set rOld = lookForNext("ele nonrec", rOld, wsOld)
Set rNew = wsNew.Range("A1")
If Not rOld Is Nothing Then
Do Until InStr(1, rOld.Formula, "ele nonrec END") 0

rOld.Copy
Set rNew = rNew.Offset(1, 0)
rNew.PasteSpecial xlPasteAll

Set rOld = lookForNext("record sent", rOld, wsOld)
rOld.Copy
rNew.Offset(0, 8).PasteSpecial xlPasteAll

Set rOld = lookForNext("global", rOld, wsOld)
rOld.Copy
rNew.Offset(0, 23).PasteSpecial xlPasteAll

Set rOld = lookForNext("o", rOld, wsOld)
rOld.Copy
rNew.Offset(0, 29).PasteSpecial xlPasteAll

Set rOld = lookForNext("ele nonrec", rOld, wsOld)
Loop
Else
MsgBox "'ele nonrec' was not found in formulas of spreadsheet"
End If
DOUJP_GOODBYE:
Set rOld = Nothing
Set rNew = Nothing
Set wsOld = Nothing
Set wsNew = Nothing
Set wb = Nothing
Exit Sub
DOUJP_ERR:
MsgBox "NUMBER: " & Err.Number & vbCrLf & "DESCRIPTION:" & vbCrLf
& Err.Description
Resume DOUJP_GOODBYE
End Sub
' - END OF CODE -

On Feb 22, 8:07 am, JohnP wrote:
Hi,

I need the following to code to loop, but each time pasting one row further
down on Sheet 2 until the Control Find function finds "Ele NonRec END".

Cells.Find(What:="ele nonrec", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Selection.Copy
Sheets("Sheet2").Select
Range("A2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="record sent", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("I2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="global", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("X2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="o", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False) _
.Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("AD2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select

Please help!! Thank you in advance.

John



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Do until loop


Thanks Jason. The document on worksheet one is a report and all data is held
in the first column, I think this means that the "Option Explicit" part does
not work. The idea is to search for the common identifier in that cell, copy
the whole cell across and then text to column on worksheet 2 once the loop
macro has run. Does that make sense?

"Jason Lepack" wrote:

Make a backup of your spreadsheet and in the backup test this code:

' - START OF CODE -
Option Explicit

Private Function lookForNext(s As String, r As Range, ws As Worksheet)
As Range
Set lookForNext = ws.Cells.Find(What:=s, After:=r,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False)
End Function

Public Sub DoUntilJohnP()

On Error GoTo DOUJP_ERR

Dim wb As Workbook
Dim wsOld As Worksheet, wsNew As Worksheet
Dim rOld As Range, rNew As Range

Set wb = ActiveWorkbook
Set wsOld = wb.ActiveSheet
Set wsNew = wb.Sheets("Sheet2")

Set rOld = wsOld.Range("A1")
Set rOld = lookForNext("ele nonrec", rOld, wsOld)
Set rNew = wsNew.Range("A1")
If Not rOld Is Nothing Then
Do Until InStr(1, rOld.Formula, "ele nonrec END") 0

rOld.Copy
Set rNew = rNew.Offset(1, 0)
rNew.PasteSpecial xlPasteAll

Set rOld = lookForNext("record sent", rOld, wsOld)
rOld.Copy
rNew.Offset(0, 8).PasteSpecial xlPasteAll

Set rOld = lookForNext("global", rOld, wsOld)
rOld.Copy
rNew.Offset(0, 23).PasteSpecial xlPasteAll

Set rOld = lookForNext("o", rOld, wsOld)
rOld.Copy
rNew.Offset(0, 29).PasteSpecial xlPasteAll

Set rOld = lookForNext("ele nonrec", rOld, wsOld)
Loop
Else
MsgBox "'ele nonrec' was not found in formulas of spreadsheet"
End If
DOUJP_GOODBYE:
Set rOld = Nothing
Set rNew = Nothing
Set wsOld = Nothing
Set wsNew = Nothing
Set wb = Nothing
Exit Sub
DOUJP_ERR:
MsgBox "NUMBER: " & Err.Number & vbCrLf & "DESCRIPTION:" & vbCrLf
& Err.Description
Resume DOUJP_GOODBYE
End Sub
' - END OF CODE -

On Feb 22, 8:07 am, JohnP wrote:
Hi,

I need the following to code to loop, but each time pasting one row further
down on Sheet 2 until the Control Find function finds "Ele NonRec END".

Cells.Find(What:="ele nonrec", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Selection.Copy
Sheets("Sheet2").Select
Range("A2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="record sent", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("I2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="global", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("X2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="o", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False) _
.Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("AD2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select

Please help!! Thank you in advance.

John




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default Do until loop

Nope, doesn't make sense at all.

Option Explicit isn't your problem. It just makes sure that all
variables are declared.

I just created code that did what yours did and then made it loop.
All yours did was copy the cell that had the formula and pasted it
into the specific cell in Sheet2.

I don't understand what you are asking. What happens when you run the
code? What should happen?

Cheers,
Jason Lepack


On Feb 22, 11:06 am, JohnP wrote:
Thanks Jason. The document on worksheet one is a report and all data is held
in the first column, I think this means that the "Option Explicit" part does
not work. The idea is to search for the common identifier in that cell, copy
the whole cell across and then text to column on worksheet 2 once the loop
macro has run. Does that make sense?



"Jason Lepack" wrote:
Make a backup of your spreadsheet and in the backup test this code:


' - START OF CODE -
Option Explicit


Private Function lookForNext(s As String, r As Range, ws As Worksheet)
As Range
Set lookForNext = ws.Cells.Find(What:=s, After:=r,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False)
End Function


Public Sub DoUntilJohnP()


On Error GoTo DOUJP_ERR


Dim wb As Workbook
Dim wsOld As Worksheet, wsNew As Worksheet
Dim rOld As Range, rNew As Range


Set wb = ActiveWorkbook
Set wsOld = wb.ActiveSheet
Set wsNew = wb.Sheets("Sheet2")


Set rOld = wsOld.Range("A1")
Set rOld = lookForNext("ele nonrec", rOld, wsOld)
Set rNew = wsNew.Range("A1")
If Not rOld Is Nothing Then
Do Until InStr(1, rOld.Formula, "ele nonrec END") 0


rOld.Copy
Set rNew = rNew.Offset(1, 0)
rNew.PasteSpecial xlPasteAll


Set rOld = lookForNext("record sent", rOld, wsOld)
rOld.Copy
rNew.Offset(0, 8).PasteSpecial xlPasteAll


Set rOld = lookForNext("global", rOld, wsOld)
rOld.Copy
rNew.Offset(0, 23).PasteSpecial xlPasteAll


Set rOld = lookForNext("o", rOld, wsOld)
rOld.Copy
rNew.Offset(0, 29).PasteSpecial xlPasteAll


Set rOld = lookForNext("ele nonrec", rOld, wsOld)
Loop
Else
MsgBox "'ele nonrec' was not found in formulas of spreadsheet"
End If
DOUJP_GOODBYE:
Set rOld = Nothing
Set rNew = Nothing
Set wsOld = Nothing
Set wsNew = Nothing
Set wb = Nothing
Exit Sub
DOUJP_ERR:
MsgBox "NUMBER: " & Err.Number & vbCrLf & "DESCRIPTION:" & vbCrLf
& Err.Description
Resume DOUJP_GOODBYE
End Sub
' - END OF CODE -


On Feb 22, 8:07 am, JohnP wrote:
Hi,


I need the following to code to loop, but each time pasting one row further
down on Sheet 2 until the Control Find function finds "Ele NonRec END".


Cells.Find(What:="ele nonrec", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Selection.Copy
Sheets("Sheet2").Select
Range("A2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="record sent", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("I2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="global", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("X2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="o", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False) _
.Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("AD2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select


Please help!! Thank you in advance.


John- Hide quoted text -


- Show quoted text -





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Do until loop


Sorry, you can probably tell that I'm new to this!!

I was having problems with the way it had pasted but it works perfectly now.
Thank you so much.

DOUJP_ERR:
MsgBox "NUMBER: " & Err.Number & vbCrLf & "DESCRIPTION:" & vbCrLf
& Err.Description
Resume DOUJP_GOODBYE
End Sub

"Jason Lepack" wrote:

Nope, doesn't make sense at all.

Option Explicit isn't your problem. It just makes sure that all
variables are declared.

I just created code that did what yours did and then made it loop.
All yours did was copy the cell that had the formula and pasted it
into the specific cell in Sheet2.

I don't understand what you are asking. What happens when you run the
code? What should happen?

Cheers,
Jason Lepack


On Feb 22, 11:06 am, JohnP wrote:
Thanks Jason. The document on worksheet one is a report and all data is held
in the first column, I think this means that the "Option Explicit" part does
not work. The idea is to search for the common identifier in that cell, copy
the whole cell across and then text to column on worksheet 2 once the loop
macro has run. Does that make sense?



"Jason Lepack" wrote:
Make a backup of your spreadsheet and in the backup test this code:


' - START OF CODE -
Option Explicit


Private Function lookForNext(s As String, r As Range, ws As Worksheet)
As Range
Set lookForNext = ws.Cells.Find(What:=s, After:=r,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False)
End Function


Public Sub DoUntilJohnP()


On Error GoTo DOUJP_ERR


Dim wb As Workbook
Dim wsOld As Worksheet, wsNew As Worksheet
Dim rOld As Range, rNew As Range


Set wb = ActiveWorkbook
Set wsOld = wb.ActiveSheet
Set wsNew = wb.Sheets("Sheet2")


Set rOld = wsOld.Range("A1")
Set rOld = lookForNext("ele nonrec", rOld, wsOld)
Set rNew = wsNew.Range("A1")
If Not rOld Is Nothing Then
Do Until InStr(1, rOld.Formula, "ele nonrec END") 0


rOld.Copy
Set rNew = rNew.Offset(1, 0)
rNew.PasteSpecial xlPasteAll


Set rOld = lookForNext("record sent", rOld, wsOld)
rOld.Copy
rNew.Offset(0, 8).PasteSpecial xlPasteAll


Set rOld = lookForNext("global", rOld, wsOld)
rOld.Copy
rNew.Offset(0, 23).PasteSpecial xlPasteAll


Set rOld = lookForNext("o", rOld, wsOld)
rOld.Copy
rNew.Offset(0, 29).PasteSpecial xlPasteAll


Set rOld = lookForNext("ele nonrec", rOld, wsOld)
Loop
Else
MsgBox "'ele nonrec' was not found in formulas of spreadsheet"
End If
DOUJP_GOODBYE:
Set rOld = Nothing
Set rNew = Nothing
Set wsOld = Nothing
Set wsNew = Nothing
Set wb = Nothing
Exit Sub
DOUJP_ERR:
MsgBox "NUMBER: " & Err.Number & vbCrLf & "DESCRIPTION:" & vbCrLf
& Err.Description
Resume DOUJP_GOODBYE
End Sub
' - END OF CODE -


On Feb 22, 8:07 am, JohnP wrote:
Hi,


I need the following to code to loop, but each time pasting one row further
down on Sheet 2 until the Control Find function finds "Ele NonRec END".


Cells.Find(What:="ele nonrec", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Selection.Copy
Sheets("Sheet2").Select
Range("A2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="record sent", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("I2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="global", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("X2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="o", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False) _
.Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("AD2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select


Please help!! Thank you in advance.


John- Hide quoted text -


- Show quoted text -




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default Do until loop

Ah, sorry. I should have warned about that.

Cheers!

On Feb 22, 12:08 pm, JohnP wrote:
Sorry, you can probably tell that I'm new to this!!

I was having problems with the way it had pasted but it works perfectly now.
Thank you so much.

DOUJP_ERR:
MsgBox "NUMBER: " & Err.Number & vbCrLf & "DESCRIPTION:" & vbCrLf
& Err.Description
Resume DOUJP_GOODBYE
End Sub



"Jason Lepack" wrote:
Nope, doesn't make sense at all.


Option Explicit isn't your problem. It just makes sure that all
variables are declared.


I just created code that did what yours did and then made it loop.
All yours did was copy the cell that had the formula and pasted it
into the specific cell in Sheet2.


I don't understand what you are asking. What happens when you run the
code? What should happen?


Cheers,
Jason Lepack


On Feb 22, 11:06 am, JohnP wrote:
Thanks Jason. The document on worksheet one is a report and all data is held
in the first column, I think this means that the "Option Explicit" part does
not work. The idea is to search for the common identifier in that cell, copy
the whole cell across and then text to column on worksheet 2 once the loop
macro has run. Does that make sense?


"Jason Lepack" wrote:
Make a backup of your spreadsheet and in the backup test this code:


' - START OF CODE -
Option Explicit


Private Function lookForNext(s As String, r As Range, ws As Worksheet)
As Range
Set lookForNext = ws.Cells.Find(What:=s, After:=r,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False)
End Function


Public Sub DoUntilJohnP()


On Error GoTo DOUJP_ERR


Dim wb As Workbook
Dim wsOld As Worksheet, wsNew As Worksheet
Dim rOld As Range, rNew As Range


Set wb = ActiveWorkbook
Set wsOld = wb.ActiveSheet
Set wsNew = wb.Sheets("Sheet2")


Set rOld = wsOld.Range("A1")
Set rOld = lookForNext("ele nonrec", rOld, wsOld)
Set rNew = wsNew.Range("A1")
If Not rOld Is Nothing Then
Do Until InStr(1, rOld.Formula, "ele nonrec END") 0


rOld.Copy
Set rNew = rNew.Offset(1, 0)
rNew.PasteSpecial xlPasteAll


Set rOld = lookForNext("record sent", rOld, wsOld)
rOld.Copy
rNew.Offset(0, 8).PasteSpecial xlPasteAll


Set rOld = lookForNext("global", rOld, wsOld)
rOld.Copy
rNew.Offset(0, 23).PasteSpecial xlPasteAll


Set rOld = lookForNext("o", rOld, wsOld)
rOld.Copy
rNew.Offset(0, 29).PasteSpecial xlPasteAll


Set rOld = lookForNext("ele nonrec", rOld, wsOld)
Loop
Else
MsgBox "'ele nonrec' was not found in formulas of spreadsheet"
End If
DOUJP_GOODBYE:
Set rOld = Nothing
Set rNew = Nothing
Set wsOld = Nothing
Set wsNew = Nothing
Set wb = Nothing
Exit Sub
DOUJP_ERR:
MsgBox "NUMBER: " & Err.Number & vbCrLf & "DESCRIPTION:" & vbCrLf
& Err.Description
Resume DOUJP_GOODBYE
End Sub
' - END OF CODE -


On Feb 22, 8:07 am, JohnP wrote:
Hi,


I need the following to code to loop, but each time pasting one row further
down on Sheet 2 until the Control Find function finds "Ele NonRec END".


Cells.Find(What:="ele nonrec", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Selection.Copy
Sheets("Sheet2").Select
Range("A2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="record sent", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("I2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="global", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("X2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="o", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False) _
.Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("AD2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select


Please help!! Thank you in advance.


John- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



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
For Each ... Next loop - need to reference the loop variable [email protected] Excel Programming 4 July 13th 06 06:12 PM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Loop Function unable to loop Junior728 Excel Programming 1 July 28th 05 10:23 AM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 09:20 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"