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

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
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

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,358
Office Version
  1. 365
Platform
  1. Windows
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

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
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,191,005
Messages
5,984,120
Members
439,872
Latest member
noaman79

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