Range with multiple columns

miami2k

Board Regular
Joined
Nov 1, 2017
Messages
55
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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
7,345
Office Version
  1. 2019
Platform
  1. Windows
Hi,
try

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

Dave
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,489
Messages
5,837,640
Members
430,506
Latest member
TonyIbbs

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
Top