Wild charakter in formula

MiGon

New Member
Joined
Oct 27, 2020
Messages
28
Office Version
  1. 2013
Platform
  1. Windows
Hi,
I have created macro which suppose to do the index matching, works fine but need to change to work with the with wildcard in the name.
Thank you
VBA Code:
Sub index_reclaims()
'
' index_reclaims
Dim w As Workbook
 
For Each w In Application.Workbooks
   If (w.Name) Like "*Summary*" Then
      Exit For
   End If
 Next w
 If Not w Is Nothing Then
 w.Activate
 Else
     MsgBox "Please open 'High Tech Wholesalers Summary Report all workbook'!"
     Exit Sub
 End If
' convert to numbers
    w.Activate
    Sheets(2).Activate
    Range("F2").Select
    ActiveCell.FormulaR1C1 = "=RC[-5]*1"
    Range("F2").Select
  
    Lastrow = Range("A" & Rows.Count).End(xlUp).Row
  
    Selection.AutoFill Destination:=Range("F2:F" & Lastrow)
    Range("F2:F" & Lastrow).Select
    Selection.Copy
    Range("A2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Columns("F:F").Select
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlToLeft
    Range("A24").Select
    Windows("Payment Master template.xlsm").Activate

    
  
'index
  
'*********************************************************************************
  Range("M2").Select
    ActiveCell.FormulaR1C1 = _
        "=INDEX('[High Tech Wholesalers Summary Report all.xls]Reclaims'!R2C4:R15C4,MATCH(RC[-12],'[High Tech Wholesalers Summary Report all.xls]Reclaims'!R2C1:R15C1,0))"
  
    Range("M2").Select
    Lastrow = Range("B" & Rows.Count).End(xlUp).Row
    Selection.AutoFill Destination:=Range("M2:M" & Lastrow)
  
'*********************************************************************************


 '    values_only Macro
'

    Lastrow = Range("B" & Rows.Count).End(xlUp).Row
    Range("M2:M" & Lastrow).Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Selection.Replace What:="#N/A", Replacement:="0", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Range("M2").Select
    Application.CutCopyMode = False

End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Do you mean this line here?
VBA Code:
   If (w.Name) Like "*Summary*" Then

Try this instead:
VBA Code:
    If InStr(w.Name, "Summary") > 0 Then

See here for details on the InStr function: MS Excel: How to use the INSTR Function (VBA)

Hi Joe4,
Sorry wasn't precise enough, firt part of the code works, only cannot figure out index match how to replace full name of the workbook with declared 'w'
not sure how to show vba should take info from 'w' again in the formula

Thanks

ActiveCell.FormulaR1C1 = _
"=INDEX('[w]Reclaims'!R2C4:R15C4,MATCH(RC[-12],'[w]Reclaims'!R2C1:R15C1,0))"
 
Upvote 0

Forum statistics

Threads
1,214,959
Messages
6,122,476
Members
449,087
Latest member
RExcelSearch

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