Activecell.offset

Fazila

Board Regular
Joined
Nov 19, 2014
Messages
163
Hi

I need to use the code below to attach a data validation list to columns K, L and M. The only thing is the row for each sheet is different hence the use of Activecell. The code I have is:

Code:
Sub IntList()'
' IntList Macro
'
   
    Range(ActiveCell.Offset(1, 0), ActiveCell.End(xlDown)).Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="=Lookups!$B$2:$B$8"
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With
    Range(ActiveCell.Offset(0, 1), ActiveCell.End(xlDown)).Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="=Lookups!$A$2:$A$8"
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With
    Range(ActiveCell.Offset(0, 2), ActiveCell.End(xlDown)).Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="=Lookups!$C$2:$C$8"
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With
End Sub

The problem is once it has finished with the first selection it does not move onto the next column but highlights both columns K and L. I have different lists for each column. How can I change the code so that after the first data validation has applied it moves on to column L and then to column M?

Thanks

Fazila
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
If you only want it to work on column K,L,M then its best to use K,L,M in the code not activecell.
 
Upvote 0
Thanks Steve

The problem is I need to make my range so that it starts from the row below the active cell and column k, then l and then m.

At the moment my range is:

K66:k90

then L66:l90

then M66: m90

The problem is for the next sheet the row number could be 70 to 200 or 76 to 150 so it means I have to go into the code each time to alter the row references.
 
Upvote 0
Ok somthing like this?

Code:
Dim rng As Range, myRow As Long

myRow = ActiveCell.Row
Set rng = Range("K" & myRow)

Range(rng.Offset(1, 0), rng.Offset(1, 0).End(xlDown)).Select
'code
Range(rng.Offset(1, 1), rng.Offset(1, 1).End(xlDown)).Select
'code
Range(rng.Offset(1, 2), rng.Offset(1, 2).End(xlDown)).Select
'code
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,329
Members
452,635
Latest member
laura12345

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