Wild Card in VBA??

sharon9999

New Member
Joined
Mar 21, 2017
Messages
20
Hi

I am importing a report, however sometimes there is a large space within the heading, eg..."Account_Number ", sometimes there isn't, eg..."Account_Number"

Rather than having to change the code every time to accommodate this space, is there a wild card I can use in VBA?

Hope this makes sense..

Thanks

SC
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
SC

What do you mean by 'heading'?

A header on a sheet?
 
Upvote 0
What code do you have at the moment?
 
Upvote 0
Yeah a heading on the sheet.
The code i have at the moment is the code to select the heading for example Account_Number.
I wanted to know if I can out "*" or something to pickup the space within the cell as well?

Basically the report is this 'Account_Number ' - with space
but sometimes the report comes through without a space.
Dont want to keep changing the code.
 
Upvote 0
Without being able to see your actual code, it's difficult to give an answer.
 
Upvote 0
here you go.....

Set foundCell = Cells.Find(what:="ACCOUNT_NUMBER ", After:=Range("A1"), LookIn:=xlValues, Lookat _
:=xlWhole, Searchorder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, Searchformat:=False)
colACCOUNT_NUMBER = foundCell.Column
 
Upvote 0
If you want to find the column the header is in try this, change Rows(1) to reflect the row the headers are actually in.
Code:
colACCOUNT_NUMBER = Application.Match("Account*Number", Rows(1), 0)
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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