vincecodegreeen
New Member
- Joined
- Jan 17, 2014
- Messages
- 39
Hi,
I have a particularly perplexing issue.
The following code sometimes works and sometimes doesn't. I am using the Else If because the Select Case couldn't find it at all. The variable is exactly as the if statement, without the "". For instance '[CN caloriecalculator.xlsm]TDC'!$B$10 should match "'[CN caloriecalculator.xlsm]TDC'!$B$10" in the code.
Also, please note that I have commented out some steps in my effort to isolate the problem.
Thanks for helping,
Vince
I have a particularly perplexing issue.
The following code sometimes works and sometimes doesn't. I am using the Else If because the Select Case couldn't find it at all. The variable is exactly as the if statement, without the "". For instance '[CN caloriecalculator.xlsm]TDC'!$B$10 should match "'[CN caloriecalculator.xlsm]TDC'!$B$10" in the code.
Also, please note that I have commented out some steps in my effort to isolate the problem.
Thanks for helping,
Vince
Code:
Sub CellAddress()
'
' Find Cell Address Macro
'
Dim mealname As String
'Dim wkb As Workbook
'Dim ws As Worksheet
'Set wkb = ThisWorkbook
'For Each ws In wkb.Worksheets
'Select Case ws.Name
'Case "TDC", "Food Cals", "Unassigned foods"
' skip
'Case Else
'ws.Activate
Range("G47").Select
'For i = 1 To 4
mealname = activecell.Value
If mealname = "'[CN caloriecalculator.xlsm]TDC'!$B$9" Then
activecell.Offset(0, -5).Value = "Meal 1, Protein"
activecell.Offset(0, -1).Value = "G5"
ElseIf mealname = "'[CN caloriecalculator.xlsm]TDC'!$B$10" Then
activecell.Offset(0, -5).Value = "Meal 1, Carbs"
activecell.Offset(0, -1).Value = "G6"
ElseIf mealname = "'[CN caloriecalculator.xlsm]TDC'!$B$11" Then
activecell.Offset(0, -5).Value = "Meal 1, Fats"
activecell.Offset(0, -1).Value = "G7"
ElseIf mealname = "'[CN caloriecalculator.xlsm]TDC'!$B$12" Then
activecell.Offset(0, -5).Value = "Meal 1, Fr/Vegs"
activecell.Offset(0, -1).Value = "G8"
Else
activecell.Offset(0, -5).Value = "None"
End If
activecell.Offset(1, 0).Select
'Next i
'End Select
'Next ws
End Sub
Last edited by a moderator: