Forestq

Active Member
Joined
May 9, 2010
Messages
482
Hi,

I want to delete one column.

Generaly It could be done like:

Code:
Columns("AY:AY").Select
Selection.Delete Shift:=xlToLeft

But how to do it in "With...."
Code:
With sourceWb.Sheets("Sheet1")
    .Range("A1:B6").EntireRow.Delete
       
    LastRow = .Range("CW65536").End(xlUp).Row
   '....delete coulmn AY here

End With
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Try
Code:
With sourceWb.Sheets("Sheet1")
    .Columns("AY").Delete
End With
 
Upvote 0
Code:
With sourceWb.Sheets("Sheet1")
       
    LastRow = .Range("CW65536").End(xlUp).Row

End With

Hi

This statement is not portable. The number of rows in a column in excel depends on the excel version.

It's better:

Code:
With sourceWb.Sheets("Sheet1")
       
    LastRow = .Range("CW" & .Rows.Count).End(xlUp).Row

End With

This will work ok for any version.
 
Upvote 0
yes I know,
but in my case I know that the number of rows always will be less then < 5000.

thank you anyway!
 
Upvote 0

Forum statistics

Threads
1,214,611
Messages
6,120,510
Members
448,967
Latest member
screechyboy79

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