Vba concatenate 2 columns that have a currency

VBA learner ITG

Active Member
Joined
Apr 18, 2017
Messages
272
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi all,

Any advice would be appreciated on this!


Column P of my workbook is a numerical column and Column Q is a Currency sign indicator, I need to add the Currency sign indicator to the front of the cell in column P or at the end depending on the currency sign indicator.

£ = UK Pounds
P = UK Pence



Column PColumn Q
1.50£
50P

<tbody>
</tbody>


so the output would look like the below
Column PColumn Q
£1.50£
50PP

<tbody>
</tbody>


Is this achieving in column P without adding another column to the table using VBA?

I have tried the below code but it will only concatenate the value at the front of the cell value.

Code:
 For i = 2 To Cells(Rows.Count, "P").End(xlUp).Row
    Cells(i, "P").Value = Cells(i, "Q").Value & "" & Cells(i, "P").Value
Next i
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
A suggestion:
Code:
For i = 2 To Cells(Rows.Count, "P").End(xlUp).Row
    Select Case Cells(i, "Q").Value
        Case Is = "£": Cells(i, "P").Value = Cells(i, "Q").Value & Cells(i, "P").Value
        Case Is = "p": Cells(i, "P").Value = Cells(i, "P").Value & Cells(i, "Q").Value
    End Select
Next i
 
Last edited:
Upvote 0
Hi JackDanIce,

Thank you for your help, i have learnt something new today :)


A suggestion:
Code:
For i = 2 To Cells(Rows.Count, "P").End(xlUp).Row
    Select Case Cells(i, "Q").Value
        Case Is = "£": Cells(i, "P").Value = Cells(i, "Q").Value & Cells(i, "P").Value
        Case Is = "p": Cells(i, "P").Value = Cells(i, "P").Value & Cells(i, "Q").Value
    End Select
Next i
 
Upvote 0
Another way :
Code:
Dim p$: p = Range("P2:P" & Cells(Rows.Count, "P").End(3).Row).Address
Dim q$: q = Range(p).Offset(0, 1).Address
Range(p) = Evaluate("IF(" & q & "=""P""," & p & "&" & q & "," & q & "&" & p & ")")
 
Last edited:
Upvote 0
hi Footoo

Thank you for your assistance, both codes have been very helpful and useful as i have learnt something new.

Another way :
Code:
Dim p$: p = Range("P2:P" & Cells(Rows.Count, "P").End(3).Row).Address
Dim q$: q = Range(p).Offset(0, 1).Address
Range(p) = Evaluate("IF(" & q & "=""P""," & p & "&" & q & "," & q & "&" & p & ")")
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

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