ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   if statement (https://www.excelbanter.com/excel-programming/285304-if-statement.html)

clui[_14_]

if statement
 
I'm loop through my data and need to set up an array based on some
conditions. Basically I'd like to do something like this:

for j=1 to 18
for rowcount=1 to 1000
if cells(rowcount,2) like "I" then
if cells(rowcount,3) like "A" or "B" or "C" then
myarray(j) = myarray(j) + cells(rowcount,4)
end if
end if
next rowcount
next j

What's the code for that? Thanks!


---
Message posted from http://www.ExcelForum.com/


Bill Manville

if statement
 
Clui wrote:
Basically I'd like to do something like this:

Dim J As Integer
Dim RowCount As Integer
J=1
For RowCount=1 to 1000
If Cells(RowCount,2) = "I" Then
Select Case Cells(RowCount,3)
Case "A", "B", "C"
myarray(j) = myarray(j) + cells(rowcount,4)
j+j+1
End Select
End If
Next RowCount

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup



All times are GMT +1. The time now is 05:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com