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

Hello

I have created a macro below, that does what I need (copies down from above
when it finds text "#N/A N/A" in a cell) and I want it to Loop until it has
removed all the "#N/A N/A" values in the worksheet. So any help with the Do
Until section would be very helpful.

Sub CopyDown()

Do Until
Sheets("BLGDataFeedCopy").Select
Columns("D:GQ").Select
Selection.Find(What:="#N/A N/A", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Cells(ActiveCell.Row - 1, ActiveCell.Column).Select
Range(Selection, Selection.Offset(1, 0)).Select
Selection.FillDown


Loop

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Loop Do Until question



Sub CopyDown()

For Each cell In Sheets("BLGDataFeedCopy").Columns("D:GQ")
if cell.row < 1 then
If cell.Value = "#N/A N/A" Then
cell.Offset(-1, 0).FillDown _
Destination:=Range(cell.Offset(-1, 0), cell)
End If
End if
Next cell
End Sub


"Barry McConnell" wrote:

Hello

I have created a macro below, that does what I need (copies down from above
when it finds text "#N/A N/A" in a cell) and I want it to Loop until it has
removed all the "#N/A N/A" values in the worksheet. So any help with the Do
Until section would be very helpful.

Sub CopyDown()

Do Until
Sheets("BLGDataFeedCopy").Select
Columns("D:GQ").Select
Selection.Find(What:="#N/A N/A", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Cells(ActiveCell.Row - 1, ActiveCell.Column).Select
Range(Selection, Selection.Offset(1, 0)).Select
Selection.FillDown


Loop

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Loop Do Until question

Thanks Joel, I copied your version in but it doesn't get rid of the "#N/A
N/A" values.

"Joel" wrote:



Sub CopyDown()

For Each cell In Sheets("BLGDataFeedCopy").Columns("D:GQ")
if cell.row < 1 then
If cell.Value = "#N/A N/A" Then
cell.Offset(-1, 0).FillDown _
Destination:=Range(cell.Offset(-1, 0), cell)
End If
End if
Next cell
End Sub


"Barry McConnell" wrote:

Hello

I have created a macro below, that does what I need (copies down from above
when it finds text "#N/A N/A" in a cell) and I want it to Loop until it has
removed all the "#N/A N/A" values in the worksheet. So any help with the Do
Until section would be very helpful.

Sub CopyDown()

Do Until
Sheets("BLGDataFeedCopy").Select
Columns("D:GQ").Select
Selection.Find(What:="#N/A N/A", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Cells(ActiveCell.Row - 1, ActiveCell.Column).Select
Range(Selection, Selection.Offset(1, 0)).Select
Selection.FillDown


Loop

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Loop Do Until question

both of these worked for me:

Sub CopyDown()
With Worksheets("BLGDataFeedCopy")
Set r = Intersect(Columns("D:GQ"), .UsedRange)
End With
For Each cell In r
If cell.Row < 1 Then
If cell.Value = "#N/A N/A" Then
cell.FillDown
End If
End If
Next cell
End Sub

Sub Copydown1()
With Worksheets("BLGDataFeedCopy")
Set r = Intersect(Columns("D:GQ"), .UsedRange)
End With
Do
Set r1 = r.Find(what:="#N/A N/A", _
After:=r(r.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not r1 Is Nothing Then
r1.FillDown
Else
Exit Do
End If
Loop
End Sub

--
Regards,
Tom Ogilvy


"Barry McConnell" wrote:

Thanks Joel, I copied your version in but it doesn't get rid of the "#N/A
N/A" values.

"Joel" wrote:



Sub CopyDown()

For Each cell In Sheets("BLGDataFeedCopy").Columns("D:GQ")
if cell.row < 1 then
If cell.Value = "#N/A N/A" Then
cell.Offset(-1, 0).FillDown _
Destination:=Range(cell.Offset(-1, 0), cell)
End If
End if
Next cell
End Sub


"Barry McConnell" wrote:

Hello

I have created a macro below, that does what I need (copies down from above
when it finds text "#N/A N/A" in a cell) and I want it to Loop until it has
removed all the "#N/A N/A" values in the worksheet. So any help with the Do
Until section would be very helpful.

Sub CopyDown()

Do Until
Sheets("BLGDataFeedCopy").Select
Columns("D:GQ").Select
Selection.Find(What:="#N/A N/A", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Cells(ActiveCell.Row - 1, ActiveCell.Column).Select
Range(Selection, Selection.Offset(1, 0)).Select
Selection.FillDown


Loop

End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Loop Do Until question

Hi,

probably not the most effecient method but try this. Alter GQ1000 to the
actual range

Sub CopyDown()
For Each c In Sheets("BLGDataFeedCopy").Range("D1:GQ1000")
If c.Value = "#N/A N/A" Then
c.Value = c.Offset(-1, 0).Value
End If
Next
End Sub

Mike


"Barry McConnell" wrote:

Thanks Joel, I copied your version in but it doesn't get rid of the "#N/A
N/A" values.

"Joel" wrote:



Sub CopyDown()

For Each cell In Sheets("BLGDataFeedCopy").Columns("D:GQ")
if cell.row < 1 then
If cell.Value = "#N/A N/A" Then
cell.Offset(-1, 0).FillDown _
Destination:=Range(cell.Offset(-1, 0), cell)
End If
End if
Next cell
End Sub


"Barry McConnell" wrote:

Hello

I have created a macro below, that does what I need (copies down from above
when it finds text "#N/A N/A" in a cell) and I want it to Loop until it has
removed all the "#N/A N/A" values in the worksheet. So any help with the Do
Until section would be very helpful.

Sub CopyDown()

Do Until
Sheets("BLGDataFeedCopy").Select
Columns("D:GQ").Select
Selection.Find(What:="#N/A N/A", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Cells(ActiveCell.Row - 1, ActiveCell.Column).Select
Range(Selection, Selection.Offset(1, 0)).Select
Selection.FillDown


Loop

End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Loop Do Until question

Second one works perfectly. Don't really understand why, but that's fine.
Thanks for your help Tom.

"Tom Ogilvy" wrote:

both of these worked for me:

Sub CopyDown()
With Worksheets("BLGDataFeedCopy")
Set r = Intersect(Columns("D:GQ"), .UsedRange)
End With
For Each cell In r
If cell.Row < 1 Then
If cell.Value = "#N/A N/A" Then
cell.FillDown
End If
End If
Next cell
End Sub

Sub Copydown1()
With Worksheets("BLGDataFeedCopy")
Set r = Intersect(Columns("D:GQ"), .UsedRange)
End With
Do
Set r1 = r.Find(what:="#N/A N/A", _
After:=r(r.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not r1 Is Nothing Then
r1.FillDown
Else
Exit Do
End If
Loop
End Sub

--
Regards,
Tom Ogilvy


"Barry McConnell" wrote:

Thanks Joel, I copied your version in but it doesn't get rid of the "#N/A
N/A" values.

"Joel" wrote:



Sub CopyDown()

For Each cell In Sheets("BLGDataFeedCopy").Columns("D:GQ")
if cell.row < 1 then
If cell.Value = "#N/A N/A" Then
cell.Offset(-1, 0).FillDown _
Destination:=Range(cell.Offset(-1, 0), cell)
End If
End if
Next cell
End Sub


"Barry McConnell" wrote:

Hello

I have created a macro below, that does what I need (copies down from above
when it finds text "#N/A N/A" in a cell) and I want it to Loop until it has
removed all the "#N/A N/A" values in the worksheet. So any help with the Do
Until section would be very helpful.

Sub CopyDown()

Do Until
Sheets("BLGDataFeedCopy").Select
Columns("D:GQ").Select
Selection.Find(What:="#N/A N/A", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Cells(ActiveCell.Row - 1, ActiveCell.Column).Select
Range(Selection, Selection.Offset(1, 0)).Select
Selection.FillDown


Loop

End Sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Loop Do Until question

I think tyhe problem with my code was I forgot a period

from:
cell.Offset(-1, 0).FillDown _
Destination:=Range(cell.Offset(-1, 0), cell)

to:
cell.Offset(-1, 0).FillDown _
Destination:=.Range(cell.Offset(-1, 0), cell)


"Barry McConnell" wrote:

Thanks Joel, I copied your version in but it doesn't get rid of the "#N/A
N/A" values.

"Joel" wrote:



Sub CopyDown()

For Each cell In Sheets("BLGDataFeedCopy").Columns("D:GQ")
if cell.row < 1 then
If cell.Value = "#N/A N/A" Then
cell.Offset(-1, 0).FillDown _
Destination:=Range(cell.Offset(-1, 0), cell)
End If
End if
Next cell
End Sub


"Barry McConnell" wrote:

Hello

I have created a macro below, that does what I need (copies down from above
when it finds text "#N/A N/A" in a cell) and I want it to Loop until it has
removed all the "#N/A N/A" values in the worksheet. So any help with the Do
Until section would be very helpful.

Sub CopyDown()

Do Until
Sheets("BLGDataFeedCopy").Select
Columns("D:GQ").Select
Selection.Find(What:="#N/A N/A", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Cells(ActiveCell.Row - 1, ActiveCell.Column).Select
Range(Selection, Selection.Offset(1, 0)).Select
Selection.FillDown


Loop

End Sub

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
Help Loop question maju Excel Programming 1 May 20th 08 03:50 PM
Loop question N.F[_2_] Excel Discussion (Misc queries) 0 July 12th 07 08:02 PM
Next and Loop Question Paige Excel Programming 3 December 5th 05 11:35 PM
Loop question Rob Excel Programming 10 September 13th 05 10:50 PM
loop question dabith Excel Programming 6 June 13th 04 05:28 PM


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