Select Case Join Application.Transpose range change

Edgarvelez

Board Regular
Joined
Jun 6, 2019
Messages
197
Office Version
  1. 2016
Platform
  1. Windows
Hi All,
Was given a code and has worked really good, however I had to make a change (Added a row in sht1) and my range is not longer ("D9:D13") and now it's now ("D9") and ("D11:D13")
Need some help fixing this line, tried a few thing but I get errors and its above my knowledge grade, any help is appreciated and thanks.

VBA Code:
    sh1.Select
    Select Case Join(Application.Transpose(sh1.Range("D9:D13").Value), "|")
    
    Case "Metric Ton|GW|Single Line|Single Line Weight"
    sh1.Range("D32").Select
    ActiveCell.FormulaR1C1 = "=ROUND((R[-6]C/R[-8]C),3)"
    sh1.Range("D33").Select
    ActiveCell.FormulaR1C1 = "=ROUND((R[-6]C/R[-9]C),3)"
    sh1.Range("A1").Select
    'GW
    sh1.Range("D26").Copy
    sh2.Cells(Rows.Count, 8).End(xlUp)(2).Resize(sh1.Range("D30").Value).PasteSpecial xlPasteValues
    Application.CutCopyMode = False
    sh1.Range("D30:D33").Select
    Selection.ClearContents
    sh1.Range("A1")
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
You could try:

VBA Code:
For Each c In sh1.Range("D9,D11:D13")
    x = x & "|" & c.Value
Next
Select Case Mid(x, 2)
'...
End Select
 
Upvote 0
What i gave has to replace

VBA Code:
Select Case Join(Application.Transpose(sh1.Range("D9:D13").Value), "|")

which is where you now have the problem.
 
Upvote 0
Another option
VBA Code:
   Select Case sh1.Range("D9").Value & "|" & Join(Application.Transpose(sh1.Range("D11:D13").Value), "|")
 
Upvote 0
Or
VBA Code:
 Select Case WorksheetFunction.Substitute(Join(Application.Transpose(Sheets("sh1").Range("D9:D13")), "|"), "|", "", 1)
 
Upvote 0
Fluff, it worked!!! and thank you so much, you guys are the best as always.

VBA Code:
Select Case sh1.Range("D9").Value & "|" & Join(Application.Transpose(sh1.Range("D11:D13").Value), "|")
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
mohadin's code won't work if there is data in D10.
 
Upvote 0

Forum statistics

Threads
1,215,684
Messages
6,126,199
Members
449,298
Latest member
Jest

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