column selection and delete

Nelboy

Board Regular
Joined
Mar 28, 2014
Messages
53
Office Version
  1. 365
Platform
  1. Windows
Dear All,

probably a simple one

could someone tell me where i am going wrong with the following

Code:
'''lngcolumn is a long variable

wskAllocations.Columns(lngColumn & ":356").Delete    ''''''''''''''lngcolumn value is 6 in this instance

'get a run-time error '1004':
'Application-defined or object-defined error

thanks in advance
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
What version of Excel are you using that has 356 columns? Mine only has 256.
Anyway, try this:
Code:
[COLOR=#333333]wskAllocations.[/COLOR]Range(Cells(1, lngcolumn), Cells(1, 256)).Delete
 
Upvote 0

Forum statistics

Threads
1,214,402
Messages
6,119,299
Members
448,885
Latest member
LokiSonic

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