Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ren Ren is offline
external usenet poster
 
Posts: 67
Default repetitive items in For each loop

Hi i have 3 sheets,

this is the code which is running,first cycle is ok. but when the item
repeats ie second time when the item comes, i want the control to goto the
balace column ie d.offset(0,3) or c.offset(0,4) to fetch the data.and insert
a row to add the quantity and balance. in sheet2 and sheet3



Sub alloc()
Dim sh1range As Range
Dim sh2range As Range
Dim sh3range As Range
Dim sh1cell As Range
Dim r1cell As Range

With Sheets("polist")
Set sh1range = .Range("F2:F" & .Cells(Rows.Count, "F").End(xlUp).Row)
End With

With Sheets("slrs")
Set sh2range = .Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row)
End With

With Sheets("fab")
Set sh3range = .Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row)
End With
For Each sh1cell In sh1range
Set c = sh2range.Find( _
what:=sh1cell, LookIn:=xlValues)
If c Is Nothing Then
sh1cell.Interior.ColorIndex = 4

Set d = sh3range.Find( _
what:=sh1cell, LookIn:=xlValues)

If d Is Nothing Then

sh1cell.Interior.ColorIndex = 5


'(if the item is found then do the following actions)
Else: sh1cell.Interior.ColorIndex = xlNone
If sh1cell.Offset(0, 2) < d.Offset(0, 2) Then
d.Offset(0, 4).Value = sh1cell.Offset(0, -1)
ElseIf sh1cell.Offset(0, 3) d.Offset(0, 2) Then
d.Offset(0, 4).Value = sh1cell.Offset(0, -1)
End If
End If
'(if the item is found then do the following actions)
ElseIf sh1cell.Offset(0, 2) < c.Offset(0, 3) Then
c.Offset(0, 5).Value = sh1cell.Offset(0, -1)
ElseIf sh1cell.Offset(0, 2) c.Offset(0, 3) Then
c.Offset(0, 6).Value = sh1cell.Offset(0, 3)

End If

'(if the required qty is not enough then goto sheet3)
'(else goto sheet1 to get the new item)

Next sh1cell
End Sub


thanks

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
selecting multiple ActiveCell items (possibly loop problem) jono_dude Excel Programming 2 December 19th 06 12:37 AM
Stopping repetitive loop execution through user form (or other ide Mike Excel Programming 8 August 18th 06 05:54 AM
repetitive Repetitive formula Excel Discussion (Misc queries) 2 June 28th 06 05:59 AM
Adding items to ComboBox in a loop? cmpcwil2[_15_] Excel Programming 3 May 4th 06 10:31 AM
Convert repetitive IF statements to array loop? bntringa[_4_] Excel Programming 5 January 27th 06 09:45 PM


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