Range with multiple columns

miami2k

Board Regular
Joined
Nov 1, 2017
Messages
58
Dear All,

I have this code to check if a value is in a column but I need to search on two columns. How can I change the definition of the range? I've tried

VBA Code:
With Sheets("Workings").Range("H:H, O:O")

but it doesn't work.

VBA Code:
a = Combo_Attività.Value
If Trim(a) <> "" Then
    With Sheets("Workings").Range("H:H")
        Set Rng = .Find(What:=a, _
                        After:=.Cells(.Cells.Count), _
                        LookIn:=xlValues, _
                        LookAt:=xlWhole, _
                        SearchOrder:=xlByRows, _
                        SearchDirection:=xlNext, _
                        MatchCase:=False)
        If Not Rng Is Nothing Then
            Application.Goto Rng, True 'value found
        Else
            MsgBox "Activity not existing" 'value not found
        End If
    End With
End If


Thank you

miami2k
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi,
try

VBA Code:
 With Sheets("Workings").Range("H:H", "O:O")

Dave
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,605
Members
449,089
Latest member
Motoracer88

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