Using arrays as the objects in IF statements...

firefiend

Board Regular
Joined
Feb 12, 2007
Messages
74
okay, I have a doozy of a problem. I'm looking for someone to point me in the right direction, not actually write the code.

essentially, I need this:

If cell.value = {userArray} and cell.offset(0, 2).value = {taskArray}
Then cell.offset(0, 2).interior.colorindex = 3

I have three different {userArray}s and {taskArray}s and there will essentially be different code for each of the arrays and that's fine.

The {userArray} is highly volatile so it needs to be generated from the spreadsheet list to make updates easy. The [taskArray} is less volatile but does change.
SRC Report Inprog-D.xls
ABCDEF
1userGrp1taskList1userGrp2taskList2userGrp3taskList3
2User1Task1User6Task2User10Task3
3User2Task2User7Task3User11Task4
4User3Task3User8Task6User12Task5
5User4Task4User9User13Task6
6User5Task5User14
7Task6User15
Sheet1


here is the data the arrays should contain.

my problem is setting up and forming the arrays so they can be used within the IF statment.

Can someone give me some tips or reference where I can learn the VBA needed to accomplish this?
 
yeah, now it makes sense. That's the beauty of coding, sometimes the quickest route isn't a straight line, lol.


that's awesome, thanks so much for the help.


Don't worry, I'm quite sure the code I've supplied is NOT the best way to accomplish your goal. I'm still learning too.

:)
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Code:
Dim retailUsers, retailProcess
retailUsers = Range("U2:U" & Cells(Rows.Count, "U").End(xlUp).Row)
retailProcess = Range("V2:V" & Cells(Rows.Count, "V").End(xlUp).Row)


here's an interesting twist. I'm the user of this Workbook is requesting that the source ranges for these arrays not be where they are... apparently he does some data manipulation and is prone to deleting to the entire sheet from time to time.

So, I'm trying to move the source ranges to another worksheet but now the arrays aren't filling properly.

I used this code to try an accomplish the task.

Code:
Dim retailUsers, retailProcess
retailUsers = Sheets("Dashboard").Range("U2:U" & Cells(Rows.Count, "U").End(xlUp).Row)
retailProcess = Sheets("Dashboard").Range("V2:V" & Cells(Rows.Count, "V").End(xlUp).Row)

Any ideas what I'm missing?



EDIT:

I've resolved the issues by adding some code to switch active sheets but this like an inefficient way of doing it... anyone know something better?

Code:
Sheets("Dashboard").Select
Dim retailUsers, retailProcess
retailUsers = Range("O2:O" & Cells(Rows.Count, "O").End(xlUp).Row)
retailProcess = Range("P2:P" & Cells(Rows.Count, "P").End(xlUp).Row)
Sheets("Time").Select
 
Upvote 0
Code:
Dim retailUsers, retailProcess 
retailUsers = Sheets("Dashboard").Range("U2:U" & Sheets("Dashboard").Cells(Rows.Count, "U").End(xlUp).Row) 
retailProcess = Sheets("Dashboard").Range("V2:V" & Sheets("Dashboard").Cells(Rows.Count, "V").End(xlUp).Row)
 
Upvote 0

Forum statistics

Threads
1,215,443
Messages
6,124,890
Members
449,194
Latest member
JayEggleton

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top