
June 4th, 2012, 03:20 PM
|
|
Registered User
|
|
Join Date: Jun 2012
Posts: 1
Time spent in forums: 3 h 5 m 42 sec
Reputation Power: 0
|
|
|
Using Variables with Range
Hi guys,
I'm sorry I am really new to Visual Basic. What I would like to do is basically access information from a different sheet and using if statements, fill in the original sheet. I want to loop the program so it keeps running till sheet2 is empty. This is what I have so far:
Sub Region_Code_check()
'
' Region_Code_check Macro
' Checks Region_Code from differences folder and sets the delivery_channel_id accordingly.
'
' Keyboard Shortcut: Ctrl+Shift+R
If ThisWorkbook.Sheets(8).Range("A1") = "RSHIP" Then
ActiveSheet.Cells(ActiveCell.row, 3).Select
ActiveCell.FormulaR1C1 = 1
Call Delivery_Point_Name
ElseIf ThisWorkbook.Sheets(8).Range("A1") = "CH" Then
ActiveSheet.Cells(ActiveCell.row, 3).Select
ActiveCell.FormulaR1C1 = 1
ElseIf ThisWorkbook.Sheets(8).Range("A1") = "CRHA" Then
ActiveSheet.Cells(ActiveCell.row, 3).Select
ActiveCell.FormulaR1C1 = 2
ElseIf ThisWorkbook.Sheets(8).Range("A1") = "CSC" Then
ActiveSheet.Cells(ActiveCell.row, 3).Select
ActiveCell.FormulaR1C1 = 3
Else
MsgBox ("Invalid Data")
End If
End Sub
|