VBA Macro ElseIf not working

JC411911

New Member
Joined
Mar 24, 2021
Messages
2
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello,
I am very very new to VBA, and hoping I can get some help. I have a worksheet that has the below two columns beginning at cells G:5 and H:5. I am needing to update column H based on values from G but getting stuck.

Column G Column H

Product (SF)Product (New Logic)
Deposit
Deposit
Deposit
Deposit
Pay
Pay
Card
Pay
Card
Pay
Card

I have built this with the values I ultimately need but nothing happens upon running. I would ultimately like to do this for the whole column range of G and H as the column is filtered before I need to run the macro. Any help or guidance would be appreciated.


Sub totn()

Dim ProductSF As String
Dim ProductNew As String

ProductSF = Range("G5").Value

If ProductSF = "Deposit" Then
ProductNew = "Deposit"

ElseIf ProductSF = "Card" Then
ProductNew = "Card"

ElseIf ProductSF = "CL" Then
ProductNew = "CL"

ElseIf ProductSF = "RE" Then
ProductNew = "RE"

ElseIf ProductSF = "Bank Op" Then
ProductNew = "F&C"

ElseIf ProductSF = "MDS" Then
ProductNew = "Credit Op"

ElseIf ProductSF = "MM" Then
ProductNew = "Deposit"

ElseIf ProductSF = " " Then
ProductNew = "Bankwide"

End If

Range("H5").Value = ProductNew

End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I did do an if function but would definitely prefer a macro as this worksheet is loaded into a new workbook each time I update.
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,186
Members
448,554
Latest member
Gleisner2

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