List Table for codes VBA

vbanewbie68

Board Regular
Joined
Oct 16, 2021
Messages
171
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Dear Sir or Madam

Please see below my screenshot and my vba lines. The Gift Appeal ID list must have 3 codes like this 22UN01,22UN03 AND 22UN02 only. If new code comes in such as 22CO06 for example then it should not be allowed to join the list of Gift Appeal ID. It converts to blank instead. Please help to create VBA codes to create a blank if a new Appeal code comes in.


1637876929478.png


VBA Codes
If (Cells(x, DonationClassification)) = "inmemory" Then
Imprt.Cells(x, GiftAppeal).Value = "22UN02"
ElseIf (Cells(x, DonationClassification)) = "incelebration" Then
Imprt.Cells(x, GiftAppeal).Value = "22UN03"
Else
Imprt.Cells(x, GiftAppeal).Value = "22UN01"
End If

Thank you in advance for your help

Regards

V
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Need some more info. Is a new classification allowed with a different ID? How are the codes coming in? Etc.

Please provide a larger sample and more examples of what would not be allowed. If same classification, but different ID, is the classification added, but leave the ID blank.

In other words we can't guess what you may encounter, you have to provide as much detail that may be needed.
 
Upvote 0
Need some more info. Is a new classification allowed with a different ID? How are the codes coming in? Etc.

Please provide a larger sample and more examples of what would not be allowed. If same classification, but different ID, is the classification added, but leave the ID blank.

In other words we can't guess what you may encounter, you have to provide as much detail that may be needed.
1638037232533.png


Hi

Thank you for your time looking at this. I have changed it to be more clearer so apologies from the previous message which was not clear.

Please see my screenshot above with a new example. As a test I have a list of Appeal ID which has 3 codes ids. When new data comes under DonationClassification: I use VBA to pull the data from it and paste it onto the Gift Appeal ID's column.

Question is that what if new code such as 22UN04 comes in and it is not on the list of Appeal code table then it should be blank or should flag up to alert me that VBA is not recognize the new code? or should you have a better idea?

Below please see my vba codes.

Hope it makes sense to you?

Best Regards

V


Sub Add_Rows_Data()


'LastRow = Imprt.Cells(1, 1).End(xlDown).Row
'How to check if a column exists in the sheet, will throw an error if it doesn't exist
'Set Imprt = ThisWorkbook.Sheets("Sheet5")
LastRow = Import.Cells(1, 1).End(xlDown).Row


DonationClassification = WorksheetFunction.Match("DonationClassification", Import.Cells(1, 1).EntireRow, 0)
GiftAppeal = WorksheetFunction.Match("Gift Appeal ID", Import.Cells(1, 1).EntireRow, 0)

If (Cells(x, DonationClassification)) = "22UN02" Then
Imprt.Cells(x, GiftAppeal).Value = "22UN02"
ElseIf (Cells(x, DonationClassification)) = "22UN03" Then
Imprt.Cells(x, GiftAppeal).Value = "22UN03"
ElseIf (Cells(x, Campaign)) = "22UN01" Then
Imprt.Cells(x, GiftAppeal).Value = "22UN01"

Else
Imprt.Cells(x, GiftAppeal).Value = ""
End If
 
Upvote 0
Hi
Does my previous email makes sense to you? If not then I am happy to send you a new example?
Best Regards
V
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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