Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
guy guy is offline
external usenet poster
 
Posts: 12
Default Do while loop error....

hello, i am a beginner...Thank you for your help!!

the inner loop was highlighted (compile error), but i don't know what's
wrong here
ps: i want to map the price in J5:J25 to the corresponding cells in
E5:E19...

__________________________________________________ _____________________________________
Sub MapPrice()

Dim i, j As Integer
Dim selection_v, selection_p As Range

i = 5
j = 5
selection_v = Range("C5:E19")
selection_p = Range("H5:J25")

Do While j <= selection_v.Rows.Count + 4

Do While i <= selection_p.Rows.Count + 4

If Range("H" & i).Value & Range("I" & i).Value = Range("C" &
j).Value & Range("D" & j).Value Then
Range("J" & i).Copy Destination:=Range("E" & j)

i = i + 1

Loop

If isBlank(Range("E" & j).Value) Then
Range("E" & j).Value = "Not found"

i = 5
j = j + 1

Loop

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Do while loop error....


You are missing "End If" in two places and "IsBlank" cannot be used
in VBA code. I substituted the Len function.
Row variables should be declared as a Long.
(you may want to do something in the bottom half of the sheet sometime)

It looks like you may not get the results you want; give it a try
and find out.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

Sub MapPrice()
Dim i As Long
Dim j As Long
Dim selection_v As Range, selection_p As Range

i = 5
j = 5
selection_v = Range("C5:E19")
selection_p = Range("H5:J25")

Do While j <= selection_v.Rows.Count + 4
Do While i <= selection_p.Rows.Count + 4
If Range("H" & i).Value & Range("I" & i).Value = _
Range("C" & j).Value & Range("D" & j).Value Then
Range("J" & i).Copy Destination:=Range("E" & j)
i = i + 1
End If
Loop

If Len(Range("E" & j).Value) 0 Then
Range("E" & j).Value = "Not found"
i = 5
j = j + 1
End If
Loop
End Sub
'------------


"guy"
wrote in message
hello, i am a beginner...Thank you for your help!!
the inner loop was highlighted (compile error), but i don't know what's
wrong here
ps: i want to map the price in J5:J25 to the corresponding cells in
E5:E19...
____________
Sub MapPrice()

Dim i, j As Integer
Dim selection_v, selection_p As Range

i = 5
j = 5
selection_v = Range("C5:E19")
selection_p = Range("H5:J25")

Do While j <= selection_v.Rows.Count + 4

Do While i <= selection_p.Rows.Count + 4

If Range("H" & i).Value & Range("I" & i).Value = Range("C" &
j).Value & Range("D" & j).Value Then
Range("J" & i).Copy Destination:=Range("E" & j)

i = i + 1

Loop

If isBlank(Range("E" & j).Value) Then
Range("E" & j).Value = "Not found"

i = 5
j = j + 1

Loop

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Do while loop error....

This line ...
If Len(Range("E" & j).Value) 0 Then
Should be ...
If Len(Range("E" & j).Value) = 0 Then
--
Jim Cone
  #4   Report Post  
Posted to microsoft.public.excel.programming
guy guy is offline
external usenet poster
 
Posts: 12
Default Do while loop error....

Thanks!!
"Jim Cone"
...
This line ...
If Len(Range("E" & j).Value) 0 Then
Should be ...
If Len(Range("E" & j).Value) = 0 Then
--
Jim Cone



  #5   Report Post  
Posted to microsoft.public.excel.programming
guy guy is offline
external usenet poster
 
Posts: 12
Default Do while loop error....

Thanks!!
"Jim Thomlinson" ...
Without looking too closely it appears as if your inner loop is missing an
end if...

If Range("H" & i).Value & Range("I" & i).Value = Range("C" &
j).Value & Range("D" & j).Value Then
Range("J" & i).Copy Destination:=Range("E" & j)
end if '???
--
HTH...

Jim Thomlinson


"guy" wrote:

hello, i am a beginner...Thank you for your help!!

the inner loop was highlighted (compile error), but i don't know what's
wrong here
ps: i want to map the price in J5:J25 to the corresponding cells in
E5:E19...

__________________________________________________ _____________________________________
Sub MapPrice()

Dim i, j As Integer
Dim selection_v, selection_p As Range

i = 5
j = 5
selection_v = Range("C5:E19")
selection_p = Range("H5:J25")

Do While j <= selection_v.Rows.Count + 4

Do While i <= selection_p.Rows.Count + 4

If Range("H" & i).Value & Range("I" & i).Value = Range("C" &
j).Value & Range("D" & j).Value Then
Range("J" & i).Copy Destination:=Range("E" & j)

i = i + 1

Loop

If isBlank(Range("E" & j).Value) Then
Range("E" & j).Value = "Not found"

i = 5
j = j + 1

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
Loop without Do error Steph Excel Programming 2 July 6th 06 07:57 PM
For..Next loop error Ian_Limbo Excel Programming 14 December 14th 04 05:49 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM
loop error Sam Excel Programming 0 September 25th 03 02:32 PM
loop error Sam Excel Programming 0 September 18th 03 02:19 PM


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