Union

Digitborn.com

Active Member
Joined
Apr 3, 2007
Messages
353
Why this is not working?
Code:
With ws
        Union(.Cells(lRow, 2).Value, .Cells(lRow, 3).Value, .Cells(lRow, 4).Value, .Cells(lRow, 5).Value, .Cells(lRow, 11).Value, .Cells(lRow, 12).Value, .Cells(lRow, 13).Value, .Cells(lRow, 14).Value, .Cells(lRow, 15).Value) = ""
   End With
Object required? Is there any other way to write it except:
Code:
With ws
        .Cells(lRow, 2).Value = ""
        .Cells(lRow, 3).Value = ""
        .Cells(lRow, 4).Value = ""
        .Cells(lRow, 5).Value = ""
        .Cells(lRow, 11).Value = ""
        .Cells(lRow, 12).Value = ""
        .Cells(lRow, 13).Value = ""
        .Cells(lRow, 14).Value = ""
        .Cells(lRow, 15).Value = ""
   End With
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
How about
Code:
myarray = array(2,3,4,5,11,12,13,14,15)
for i = 0 to worksheetfunction.counta(myarray) - 1
      ws.Cells(lRow, myarray(i)).Value = ""
Next i
 
Upvote 0
Why are you using Value for all the ranges within the Union?
Code:
With ws
    Union(.Cells(lrow,2).Resize(,4), .Cells(lrow,11).Resize(,5))=""
End With

jonmo

You should take a look at LBound and UBound when working with arrays in VBA.:)
 
Upvote 0
You should take a look at LBound and UBound when working with arrays in VBA.

I know, I'm still learning. I see Lbound and Ubound used alot on this forum, but have no idea what they do. I guess that's what I get for self teaching....LOL. Going to look into it though, thanks.
 
Upvote 0

Forum statistics

Threads
1,215,823
Messages
6,127,064
Members
449,357
Latest member
donna_koenig

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