VBA concatenate string and wildcard "*" not working

astrbac

Board Regular
Joined
Jan 22, 2015
Messages
55
Hi all,

a stupid (I guess) problem - I cannot get my Sub() to work if I concatenate a "*" wildcard to a string.

Code that works
Code:
For i = 1 To StringsCount
                        arrStrings(i, 1) = .Range("A" & i + k).Value & "_" & .Range("C" & i + k).Value & "_" & .Range("D" & i + k).Value & "_" & .Range("E" & i + k).Value
                        arrStrings(i, 2) = .Range("A" & i + k).Row
                        
                            k = k + 11
                Next i


Code that doesn't work
Code:
For i = 1 To StringsCount
                        arrStrings(i, 1) = .Range("A" & i + k).Value & "_" & .Range("C" & i + k).Value & "_" & .Range("D" & i + k).Value & "_" & .Range("E" & i + k).Value[COLOR=#ff0000] [B]& "*"[/B][/COLOR]
                        arrStrings(i, 2) = .Range("A" & i + k).Row
                        
                            k = k + 11
                Next i

Here is the sheet where I lift strings into VB array, AMOUNT is the cell where I need to write back into:

MarketchannelcampaignproductAMOUNT
Belgiumgdnjanuarynp

<tbody>
</tbody>




It is a part of a larger procedure that compares two 2 dimensional arrays (string to another string) and if it finds a match it adds to a temporary SUM. When done comparing all strings, it should write back to a range but it writes all zeroes if I use "*" version".

Why do I need a "*"? Because it is possible that there are a few similar strings that I want summed and written into one row.

Example:
Belgium_gdn_january_np_(FL) 500.00
Belgium_gdn_january_np_(EN) 750,00
Belgium_gdn_january_np_(NL) 630.00

I want it summed into row #x, that has the string
Belgium_gdn_january_np 1880.00

Thanks!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I forgot to mention in the original thread, the block that "doesn't work" esentially breaks this block and the line in red which writes all yeroes:

Code:
'-------------------- perform search and write into destination
interSum = 0


      For i = 1 To UBound(arrStrings)
          For j = LBound(arrCampaignsAmounts, 1) To UBound(arrCampaignsAmounts, 1)
              If arrStrings(i, 1) = arrCampaignsAmounts(j, 1) Then
                  interSum = interSum + arrCampaignsAmounts(j, 2)  
              End If
           Next j
[COLOR=#ff0000]              
              SourceSheet.Range("H" & arrStrings(i, 2)).Value = interSum[/COLOR]
              interSum = 0
      Next i
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,618
Members
449,092
Latest member
amyap

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