Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Afternoon all,
I'm trying to update one range from another, I've been pulling one cell value from the "feed" range that I'm updating from, and then comparing it to each cell value of the "check" range, if the value matches up, then the feed range is re-selected, the next cell value is chosen, and the cycle starts over again. I've managed to get this far, but I'm trying to figure out how to write the code so that, after it compares the "feed" value to the "check" range and doesn't find a match, then it goes to the bottom of the "check" range and inserts a row, at which point it will go back to the "feed" range, select the next value and continue as before. I know the code necessary to get to the bottom of the range and insert the row, but I can't figure out exactly where to put it in regards to the different loops I'm using. Here's what I've got so far: ' Open G-A-C Workbook to look up loan #'s Workbooks.Open Filename:= _ "feed.xls" _ , UpdateLinks:=0 'Define how many new loans & how many new rows to insert Dim Startrow As Integer Dim Endrow As Integer Dim Loansytd As Integer Startrow = 10 Range("B10:B150").Select Selection.End(xlDown).Select ActiveCell.Offset(1, 0).Select Endrow = ActiveCell.Row Loansytd = Endrow - Startrow 'Set up For loop Dim loannum As String Range("B10").Select Dim searchfield As Range Windows("check.xls").Activate Set searchfield = Range("B2:B150") Windows("feed.xls").Activate 'Start For loop For i = 1 To Loansytd loannum = ActiveCell.Value Windows("check.xls").Activate Set searchfield = Range("B2:B150") searchfield.Activate 'Search for Loan # For Each searchfield In Range("B2:B150") If searchfield.Value2 = loannum Then Windows("feed.xls").Activate ActiveCell.Offset(1, 0).Select Exit For End If Next searchfield Next i End Sub I know this is probably an absolute mess, but I'd appreciate any help or suggestions you guys (& girls) might have to offer? Once thing that might bear mentioning: - the sequence of the cells & values can't be disturbed, otherwise I'd use a vlookup. Any help is greatly appreciated! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel - Negative nested if then conditions | Excel Discussion (Misc queries) | |||
Complicated!! - Conditional formatting with nested function | Excel Worksheet Functions | |||
Nested loop | Excel Worksheet Functions | |||
ADO command.execute with a loop - only runs once | Excel Programming | |||
Nested Loop | Excel Programming |