PDA

View Full Version : [SOLVED] VBA CellMovement from ActiveCell



DipPatel
11-17-2016, 10:48 PM
Hello VBA Coders,

I'm in desire need of help with my code that I am writing.

I have this code, provided below.

The movements are set for each scenario.
For yyy I will be moving 1 row up and 2 columns left to gain the value. or 2 rows up and 2 columns left.(From current active cell.)
For zzz I wil be moving either one row up or two rows up. (From Current Active Cell.)

I just want to use the values of yyy and zzz in my input box prompt.

I have been using different methods (r1c1, offset, and xlup, etc) and have been failing. Any help or sense of direction would be helpful as I have been struggling for hours.

Sub test()


Set lol = ActiveCell
Dim yyy As Range
Dim zzz As Range


If lol.Offset(1, 0).Value = "" Then
yyy = lol.Offset(-1, -2).Value
zzz = lol.Offset(-1, 0).Value
Else
yyy = lol.Offset(-2, -2).Value
zzz = lol.Offset(-2, 0).Value
End If


MsgBox "zzz & yyy"




End Sub

p45cal
11-18-2016, 04:29 AM
try removing all instances of As Range,





and change:
MsgBox "zzz & yyy"to:
MsgBox zzz & yyy

DipPatel
11-18-2016, 08:28 AM
try removing all instances of As Range,





and change:
MsgBox "zzz & yyy"to:
MsgBox zzz & yyy

I have the references working, but now in my input box it won't appear as the values they select, but instead appear as the names *** and yyy.
Edit = InputBox("Please enter the new price for the Model: & zzz &. The original price of this Model is & yyy &.")

p45cal
11-18-2016, 09:19 AM
Edit = InputBox("Please enter the new price for the Model:" & zzz & " The original price of this Model is " & yyy & ".")