Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
returning back to loop check condition without completing the loop | Excel Programming | |||
Loop to Filter, Name Sheets. If Blank, Exit Loop | Excel Programming | |||
(Complex) Loop within loop to create worksheets | Excel Programming | |||
Advancing outer Loop Based on criteria of inner loop | Excel Programming | |||
Problem adding charts using Do-Loop Until loop | Excel Programming |