Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Columns Help

Status
Not open for further replies.

aubie8

IS-IT--Management
Jul 9, 2001
7
US
Hi all!

I have a question..

I recorded a macro that deletes the first column from a spreadsheet (its the last spreadsheet in the workbook). I shift all the cells left. Then I delete columns B thru G. What I am after is the data in column 2 from the original columns. It worked fine. I then copied the code and put it behind a button.

Now, when I run this code, the first column selection selects columns A thru H. I don't understand why it is doing that.

Can anyone help?

Thanks!!

ps. Here is my code.

Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Columns("B:G").Select
Selection.Delete Shift:=xlToLeft
ActiveWindow.SmallScroll Down:=18
Rows("37:38").Select
Selection.Delete Shift:=xlUp
 
runs alright at this end....
Is that your entire code???
 
It ran fine here the first time, now it doesn't work properly.

no, there is some more code after that that performs tasks on the information in the one column that is left and then copies it to another sheet. but it is not even getting past that first

Columns("A:A").Select

when it hits this line, it selects every column that has data in them. this is a sub-procedure that is called from a button. that all seems to be working correctly.

i decided to try some other things, range("a1:a43") and it does the same thing. selects the whole range with data, not just column A.

i even went back and recorded the macro again. when i inserted it into the module and ran it, it gives me the same results.
 
here your code runs correctly every time
So I am afraid I can't help you
I would try copying the data you are interested in to another worksheet to get around the problem
Not the best thing I know but it may help
 
Thanks for your help...

I tried this.. Rebooted the computer, several times.. One thing that did happen and I have no idea if this is a factor or not. I reformatted my computer and installed W2K instead of Windows98. HAd to reinstall the Office products. Thats when it did'nt work.

After it wouldn't work, I rebooted several times. Then I went back in this morning and tried again, dang if it didn't work this time!!!!!!!!!!!!!!!!!!!!!!!

I wonder if it had something to do with trying to run the first times after changing operating systems. who knows...

I'll test it for another week and see what happens, cuz it should work everytime. Its a very simple thing and I didn't even write the code, just recorded it.

chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top