VBA Index/Match that refers to a second worksheet?

KDS14589

Board Regular
Joined
Jan 10, 2019
Messages
203
Office Version
  1. 2016
Platform
  1. Windows
I’m having problem with my VBA Index/Match for the ‘’’’Detail section color name’’’’ because it refers to another worksheet for the first part of the Match.

The Index/Match for ‘’’’Tab/Cells Color name’’’’ works fine because all the refers to are for the same worksheet it’s on.


VBA Code:
‘’’’Tab/Cells Color name’’’’

For rowdata = RowDataStart To RowDataEnd

Range("A36:A37").ClearContents

Range("A36").Value = ShGE03.Name & " cell interior color and Tab color is " & _

WorksheetFunction.Index(ShGE03.Range("D5:D" & rowdata), _

WorksheetFunction.Match(ShGE03.Range("A5"), ShGE03.Range("v5:v" & rowdata), 0))

Range("A37").Value = _

WorksheetFunction.Index(ShGE03.Range("H5:H" & rowdata), _

WorksheetFunction.Match(ShGE03.Range("A5"), ShGE03.Range("v5:v" & rowdata), 0)) _

& " and " & _

WorksheetFunction.Index(ShGE03.Range("B5:B" & rowdata), _

WorksheetFunction.Match(ShGE03.Range("A5"), ShGE03.Range("V5:V" & rowdata), 0)) _

& " and Ligtness of " & _

WorksheetFunction.Index(ShGE03.Range("R5:R" & rowdata), _

WorksheetFunction.Match(ShGE03.Range("A5"), ShGE03.Range("V5:V" & rowdata), 0))

Next


This part not working.
VBA Code:
‘’’’Detail section color name’’’’

For rowdata = RowDataStart To RowDataEnd

Dim Sheet1 As Worksheet

Set Sheet1 = Worksheets("General.ColorNames") 'CODENAME ShGE03

Dim Sheet2 As Worksheet

Set Sheet2 = Worksheets("Controls.General") 'CODENAME ShCO01

Range("A38:A39").ClearContents

Range("A38").Value = "All worksheets 'Detail' section cells interior color is " & _

WorksheetFunction.Index(Sheet1.Range("D5:D" & rowdata), _

WorksheetFunction.Match(Sheet2.Range("Q29"), Sheet1.Range("v5:v" & rowdata), 0))

Range("A39").Value = _

WorksheetFunction.Index(Sheet1.Range("H5:H" & rowdata), _

WorksheetFunction.Match(Sheet2.Range("Q29"), Sheet1.Range("v5:v" & rowdata), 0)) _

& " and " & _

WorksheetFunction.Index(Sheet1.Range("B5:B" & rowdata), _

WorksheetFunction.Match(Sheet2.Range("Q29"), Sheet1.Range("V5:V" & rowdata), 0)) _

& " and Ligtness of " & _

WorksheetFunction.Index(Sheet1.Range("R5:R" & rowdata), _

WorksheetFunction.Match(Sheet2.Range("Q29"), Sheet1.Range("V5:V" & rowdata), 0))

Next


Can anyone help with an Index/Match that refers to a second worksheet?
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I’m having problem with my VBA Index/Match for the ‘’’’Detail section color name’’’’ because it refers to another worksheet for the first part of the Match.

The Index/Match for ‘’’’Tab/Cells Color name’’’’ works fine because all the refers to are for the same worksheet it’s on.


VBA Code:
‘’’’Tab/Cells Color name’’’’

For rowdata = RowDataStart To RowDataEnd

Range("A36:A37").ClearContents

Range("A36").Value = ShGE03.Name & " cell interior color and Tab color is " & _

WorksheetFunction.Index(ShGE03.Range("D5:D" & rowdata), _

WorksheetFunction.Match(ShGE03.Range("A5"), ShGE03.Range("v5:v" & rowdata), 0))

Range("A37").Value = _

WorksheetFunction.Index(ShGE03.Range("H5:H" & rowdata), _

WorksheetFunction.Match(ShGE03.Range("A5"), ShGE03.Range("v5:v" & rowdata), 0)) _

& " and " & _

WorksheetFunction.Index(ShGE03.Range("B5:B" & rowdata), _

WorksheetFunction.Match(ShGE03.Range("A5"), ShGE03.Range("V5:V" & rowdata), 0)) _

& " and Ligtness of " & _

WorksheetFunction.Index(ShGE03.Range("R5:R" & rowdata), _

WorksheetFunction.Match(ShGE03.Range("A5"), ShGE03.Range("V5:V" & rowdata), 0))

Next


This part not working.
VBA Code:
‘’’’Detail section color name’’’’

For rowdata = RowDataStart To RowDataEnd

Dim Sheet1 As Worksheet

Set Sheet1 = Worksheets("General.ColorNames") 'CODENAME ShGE03

Dim Sheet2 As Worksheet

Set Sheet2 = Worksheets("Controls.General") 'CODENAME ShCO01

Range("A38:A39").ClearContents

Range("A38").Value = "All worksheets 'Detail' section cells interior color is " & _

WorksheetFunction.Index(Sheet1.Range("D5:D" & rowdata), _

WorksheetFunction.Match(Sheet2.Range("Q29"), Sheet1.Range("v5:v" & rowdata), 0))

Range("A39").Value = _

WorksheetFunction.Index(Sheet1.Range("H5:H" & rowdata), _

WorksheetFunction.Match(Sheet2.Range("Q29"), Sheet1.Range("v5:v" & rowdata), 0)) _

& " and " & _

WorksheetFunction.Index(Sheet1.Range("B5:B" & rowdata), _

WorksheetFunction.Match(Sheet2.Range("Q29"), Sheet1.Range("V5:V" & rowdata), 0)) _

& " and Ligtness of " & _

WorksheetFunction.Index(Sheet1.Range("R5:R" & rowdata), _

WorksheetFunction.Match(Sheet2.Range("Q29"), Sheet1.Range("V5:V" & rowdata), 0))

Next


Can anyone help with an Index/Match that refers to a second worksheet?
I solved it myself! The reference should have been: ("P29") 'DUUH' I feel about 1" tall. SORRY
WorksheetFunction.Match(Sheet2.Range("Q29")
 
Upvote 0
Solution

Forum statistics

Threads
1,224,812
Messages
6,181,096
Members
453,021
Latest member
Justyna P

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