VBA Set Named Range

DRWonoski

Board Regular
Joined
Mar 20, 2014
Messages
99
In a workbook I have titles to a table in Row 2. I want to set a named column based on those titles as publicly accessible throughout all of the code in the workbook. I'm currently getting a Compile Error: Type Mismatch with .Match being highlighted. Thoughts?

Code:
 Public ColPWSN As Range
Code:
Set ColPWSN = WorksheetFunction.Match("PW SN", ActiveWorkbook.ActiveSheet.Range("2:2"), 0)
 
Here's the big picture - I have a few different stores that all track orders using an excel spreadsheet similar to what you see below. Each one is named "Town Order Tracker". I also have a "master" file that feeds all of the columns you see highlighted in tan. "Pull2" comes from Master!Sheet1 and "Pull1" comes from Master!Sheet2,3,4,5, or 6 (each store has their own sheet. All information is found on Pull1 first, and then when entered into our ERP system it gets moved to pull2 (AKA anything that shows Pull2 currently has a formula to state "TBD" until a match is found on Pull2.

I want an easier way to add new lines and mark orders as shipped. When orders ship, I currently copy everything and paste as values so the index(match isn't lost when orders fall off of Pull1. I then change a column to say "closed" instead of open.

To add a new order, I want an input box to appear asking for the PO number. I then want excel to look in "Pull2" to determine whether it is "Cat, Dog, or Elephant" and place a new formatted line below the last of that type. All tan shaded boxes should automatically pull from Pull1 or Pull2. If the PO isn't found, I want the employee to be able to manually enter whatever Cat or Dog and then manually add any Pull 1 Information.

Before State: https://imgur.com/eKLjNil
After Adding New Dog: https://imgur.com/yTTrKlY
After "Shipping" Dog: https://imgur.com/Klsvmv0
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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