VBA for Data Validation "Input message" text from offset cell value

edgarsrom

New Member
Joined
May 7, 2014
Messages
34
Office Version
  1. 2013
Hello,

could anybody help with VBA code please? I am not sure if it is even possible, below is what I am trying to achieve:

For example, I have column "A" with various text string values(notes).

Say A1= Action text 1
A2 = Action text 2
A3 = Action text 3

all the way down to the LastRow

Now, I would like to pick up cell values from Range("A1:A" & LastRow) all values and add them into Data Validation --> "Input Message" into column "B"

Something like that:

Code:
Sub ValidationTest()
Dim LastRow As Long


LastRow = Cells(Rows.Count, 1).End(xlUp).Row
    With Range("b2:b" & LastRow).Validation
        .Delete
        .Add Type:=xlValidateInputOnly, AlertStyle:=xlValidAlertStop, Operator _
        :=xlBetween
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = "ACTION TEXT"
        .ErrorTitle = ""
        .InputMessage = ???
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With
End Sub

I am not able to figure out how to add offset(,-1) value for each cell in "B" column into .InputMessage =

Any help much appreciated!

Thanks
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Perhaps:-
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim LastRow As Long

If Target.Column = 2 Then
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
    With Range("b2:b" & LastRow).Validation
        .Delete
        .Add Type:=xlValidateInputOnly, AlertStyle:=xlValidAlertStop, Operator _
        :=xlBetween
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = "ACTION TEXT"
        .ErrorTitle = ""
        .InputMessage = Target.Offset(, -1).Value
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,880
Messages
6,175,154
Members
452,615
Latest member
bogeys2birdies

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