how to write cell with wild cards

Jake975

Board Regular
Joined
Feb 9, 2020
Messages
114
Office Version
  1. 2016
Platform
  1. Windows
im using this code to fill a number on a different sheet. But how can i fill a cell with wild cards as I cant define the end if the filename prior to the extension?
VBA Code:
    For Each rng In WS2.Range("C2", WS2.Range("C" & WS2.Rows.Count).End(xlUp))
        Set fnd = WS1.Range("A:A").Find(rng, LookIn:=xlValues, lookat:=xlPart)
        If Not fnd Is Nothing Then
            fnd.Offset(, 1) = rng.Offset(, 1)
        End If
    Next rng
search nameexample file namecorrect namefinal orderpacket apacket b
logo_foliologo_folio3763012.pdflogo_folio3763012.pdf
100​
3​
RMRM9006.pdfRM9006.pdf
100​
3​
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

johnnyL

Well-known Member
Joined
Nov 7, 2011
Messages
3,972
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
Not sure what you are asking for exactly, but a 'wildcard' of '?' equates to one wild card character, a '*' as a wildcard equates to any amount of characters. That help?
 

Jake975

Board Regular
Joined
Feb 9, 2020
Messages
114
Office Version
  1. 2016
Platform
  1. Windows
My apologies I didn't think I would put wildcards in the location like that I will test it tonight to make sure it docent interfere with another part of the application when it renames files to the correct filename.
one other question is if I have more then one file with a similar name it isn't providing a return value for the subsequent files how can I correct this?

search nameexample file namecorrect namefinal orderpacket apacket b
logo_folio
logo_folio3763012.pdf
logo_folio3794357.pdf
logo_folio*.pdf
1003
RM
RM9006.pdf
RM9500.pdf
RM*.pdf1003
 

johnnyL

Well-known Member
Joined
Nov 7, 2011
Messages
3,972
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
@Jake975 If you are asking for the wildcard solutions ...

The following should yield the same results:
logo_folio376????.pdf
&
logo_folio376*.pdf

Also:
logo_folio379????.pdf
&
logo_folio379*.pdf


Other file:
RM90??.pdf
&
RM90*.pdf

Also:
RM95??.pdf
&
RM95*.pdf
 

Jake975

Board Regular
Joined
Feb 9, 2020
Messages
114
Office Version
  1. 2016
Platform
  1. Windows
update
Unfortunately can't use wildcards in the file name like that as the other part of the application tries to name the file with the wildcard I will create a new post when I can think of how to rephrase the question to get a better direction.
Thank you for your help and time
 

Forum statistics

Threads
1,181,677
Messages
5,931,368
Members
436,788
Latest member
er19

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
Top