Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default integer value won't change

I have a procedure which contains the following:
------------------------------------------------------------------------------------------------------------------------------
Dim i as integer
Dim r as integer

CheckCSXU:
i = 3
r = 1

For Each ccell In Sheets("COMPARED").Range(Cells(1, 1), _
Cells(65535, 1).End(xlUp)) 'cycle through COMPARED sheet
comparedvalue = ccell.Value

Do
With Sheets(sheettitle)
csxuvalue = .Cells(i, r).Value
End With

If i 22 And r < 14 Then
i = 3 And r = r + 3 ***PROBLEM HERE***
End If

If i 22 And r = 14 Then
i = 26 And r = 2
End If

If i 54 And r < 14 Then
i= 26 And r = r + 3
End If

If i 45 And r = 14 Then
GoTo Continue 'calls next sheet in workbook
End If

If comparedvalue = csxuvalue Then 'found a match, so add the date
next to compared cell
Sheets("COMPARED").Select
ccell.Offset(0, 2).Value = Sheets(sheettitle).Cells(i, r +
1).Value
i = i + 1
Else
i = i + 1
End If
Loop Until i = 45 And r = 13
Next ccell 'next cell in "COMPARED" sheet
------------------------------------------------------------------------------------------------------------------------------
Problem is that when the first condition is met (i 22 And e < 14) I would
like i to now equal 3, and r to equal 4, but this doesn't happen. i changes
from 1 to 0 and r stays at 1. Could someone help a novice out?

Thanks for your time...


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default integer value won't change

Steve,

You can't use the AND statement to execute multiple statements in one line.
It is a boolean operator. Change this

If i 22 And r < 14 Then
i = 3 And r = r + 3 ***PROBLEM HERE***
End If

To this:

If i 22 And r < 14 Then
i = 3
r = r + 3
End If

Robin Hammond
www.enhanceddatasystems.com

"Steve" wrote in message
ink.net...
I have a procedure which contains the following:
------------------------------------------------------------------------------------------------------------------------------
Dim i as integer
Dim r as integer

CheckCSXU:
i = 3
r = 1

For Each ccell In Sheets("COMPARED").Range(Cells(1, 1), _
Cells(65535, 1).End(xlUp)) 'cycle through COMPARED sheet
comparedvalue = ccell.Value

Do
With Sheets(sheettitle)
csxuvalue = .Cells(i, r).Value
End With

If i 22 And r < 14 Then
i = 3 And r = r + 3 ***PROBLEM HERE***
End If

If i 22 And r = 14 Then
i = 26 And r = 2
End If

If i 54 And r < 14 Then
i= 26 And r = r + 3
End If

If i 45 And r = 14 Then
GoTo Continue 'calls next sheet in workbook
End If

If comparedvalue = csxuvalue Then 'found a match, so add the date
next to compared cell
Sheets("COMPARED").Select
ccell.Offset(0, 2).Value = Sheets(sheettitle).Cells(i, r +
1).Value
i = i + 1
Else
i = i + 1
End If
Loop Until i = 45 And r = 13
Next ccell 'next cell in "COMPARED" sheet
------------------------------------------------------------------------------------------------------------------------------
Problem is that when the first condition is met (i 22 And e < 14) I
would like i to now equal 3, and r to equal 4, but this doesn't happen. i
changes from 1 to 0 and r stays at 1. Could someone help a novice out?

Thanks for your time...




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
How do I add an integer to an existing integer? Aaron Excel Worksheet Functions 3 December 17th 09 09:46 PM
integer integer format Excel Worksheet Functions 1 May 3rd 07 06:45 PM
Excel ActiveX Scrollbar - change from integer to decimal Tonette Excel Discussion (Misc queries) 2 October 15th 05 03:41 PM
Get next Integer value Stuart[_5_] Excel Programming 7 February 16th 04 04:48 AM
Not seeing integer Martin Wheeler Excel Programming 1 September 4th 03 03:29 AM


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