Donaghy


Hi all,

I have a section of code in my macro which tells it to delete a selection of columns:

Columns("C:F").Select
Selection.Delete Shift:=xlToLeft

this is the first bit of code in my macro but isn't working correctly. Instead of deleting columns C to F its deleting columns A to H.

Any ideas why this could be happening




Re: Problem: Macro not deleting columns I select

Andy Pope


Hi,

Your code in an isolated test does exactly as expected.
Selects columns C:F and deletes them.

Have you used the debugger to step through the lines of code
F8 will step you through line at a time so you can see exactly what is happening.

You might also want to consider posting some more of your code.






Re: Problem: Macro not deleting columns I select

Donaghy

Yeah I've used the debug function but it doesn't help clear up the issue. The select columns code is the very first piece of code used and when i debug through that section it shows columns A to H being highlighted .. very strange




Re: Problem: Macro not deleting columns I select

Andy Pope

Strange indeed ;)

If you want to email your file I will take a look see.
My profile has a web address that contains a usable contact email.





Re: Problem: Macro not deleting columns I select

Donaghy

Thanks for the offer but the spreadsheet contains some sensitive data that my boss wouldn't be impressed about me sharing

I think i have a workaround that will have to do, going to loop through each row and take the cells i need and paste into a new worksheet. Did a quick test and it seemed to work





Re: Problem: Macro not deleting columns I select

Andy Pope

I understand the sensitive nature of your data but does the workbook actually need any data
Nothing in the code you posted suggests it is using the actual data to control anything.






Re: Problem: Macro not deleting columns I select

Donaghy

Its more about filtering and removing data so I am only left with the 4 required columns and the data for the columns. I am then pulling this data from this worksheet into another worksheet and doing a compare with other data but they need to be in a specific format.

The workaround seemed to work though but that problem is still very odd