LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
GH GH is offline
external usenet poster
 
Posts: 11
Default Do Until or For Loop


I'm having trouble with the following code. The idea is to find a specific
value and then take an offset cell three below and one left; then CTRL+SHIFT
down to select all non-blank cells and for each cell in that range insert the
found value 5 cells to the left.

I've tried doing it with a do while loop and a for loop. With the do while
loop, it doesn't pick up the non-blank cell and overflows. The for loop
works once, but when I ran it for the next value to be found it goes back to
the first range not the new range. Any suggestions would be helpful.

Sub ModelFormat(Mandate, MgrRange)
Dim oCell As Range
Dim counter As Integer

'Stop
Cells.Select
Selection.Find(What:=Mandate, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
'Stop
'ActiveCell.Select
counter = 0
'Mandate = ActiveCell.Value

Range(ActiveCell.Offset(3, -1), ActiveCell.Offset(3, -1)).Select
'Stop
Range(Selection, Selection.End(xlDown)).Select
'Stop

ActiveWorkbook.Names.Add Name:=MgrRange, RefersToR1C1:= _
"='MVIEW Dump'!R6C1:R43C1"
Stop
'Do While ActiveCell.Value < "~WORK.CAP"
' Range(ActiveCell.Offset(counter, 5), ActiveCell.Offset(counter,
5)).Value = Mandate
'Range(ActiveCell.Offset(counter, 5), ActiveCell.Offset(counter,
5)).Select
'Range(ActiveCell.Offset(counter, -5), ActiveCell.Offset(counter,
-5)).Select
'Range(Selection, Selection.End(xlDown)).Select
' counter = counter + 1
'Loop

For Each oCell In Range(MgrRange)

Range(oCell.Offset(0, 5), oCell.Offset(0, 5)).Value = Mandate
' Stop
Next oCell

'ActiveWorkbook.Names(MgrRange).Delete

End Sub


 
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
returning back to loop check condition without completing the loop ashish128 Excel Programming 13 April 3rd 08 12:53 PM
Loop to Filter, Name Sheets. If Blank, Exit Loop ryguy7272 Excel Programming 3 February 5th 08 03:41 PM
(Complex) Loop within loop to create worksheets klysell Excel Programming 1 March 20th 07 12:03 AM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM


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