Automatically look up a table in another sheet and change cell values accordingly?

Jockdk

New Member
Joined
Jun 13, 2011
Messages
1
Hi Guys,

I'm fairly new to VBA so I was wondering if anyone could please help me with an issue?

I basically have a macro that copies data from one sheet, transposes it and then convets the cell data into another value.

I can do this in a static way by manually typing in every variable like this......


Sub ChangeValuesInTable()
' This will change the values to match the correct ones in the new sheet
Dim my1check As Boolean
endrange = Range("A65000").End(xlUp).Row
For i = 4 To endrange

'Column D Only
Column = "D"
'Leave
my1check = Range(Column & i).Value Like "1*"
If my1check = True Then
Range(Column & i).Value = "Leave"
End If
....
Etc Etc Etc
....
my5check = Range(Column & i).Value Like "C/O*"
If my5check = True Then
Range(Column & i).Value = "A 09.00-17.00"
Range(Column & i + 1).Value = "A 17.00-09.00"
End If

Next i

This works a treat for one user. The problem is that I have to type in every variable for every column up to AH. This takes ages and is not dynamic.

Rather than type every variable manually I'd like to get Excel to look up a table/sheet where all of these variables are set by the user. This is because they will have to be variable depending upon the user.
e.g "1"= "Leave" for one user but another guy using the macro might want "L"= "Leave".

I have tried various ways but I'm getting the syntax wrong or I shouldn't be using the "If" function or maybe I should be using something else?

Any help is really appreciated guys.

Cheers
Dave
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,224,597
Messages
6,179,813
Members
452,945
Latest member
Bib195

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