Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Diane Collins   on Nov 21 In MS Office Category.

  
Question Answered By: Chad Bradley   on Nov 21

"Is there some way to reference the column coordinate on a cell  I
click before calling the macro?"

instead of x = 3 have:
x = selection.column

BTW, if you were to put:

Range(Cells(y + 1, x), Cells(y + 9, x)).Delete Shift:=xlUp

instead of:
For inc = 1 To 9
Cells(y + 1, x).Select
Selection.Delete Shift:=xlUp
Next inc

it would work faster and give you the same result (it deletes 9 cells
at a time and doesn't spend time selecting cells).

But wait... you're doing this on several columns? Are the columns all
next to each other? If so then delete  all the relevant columns at the
same time. Replace entire macro code with:

Application.ScreenUpdating = False
x = Selection.Cells(1, 1).Column
z = Selection.Columns.Count + x - 1
For y = 1 To 3500
Range(Cells(y + 1, x), Cells(y + 9, z)).Delete Shift:=xlUp
Next y
Application.ScreenUpdating = True

To use, select the columns (or a range containing the columns) you
want to trim down and run it. The ScreenUpdating thing further cuts
down processing time.

Share: 

 

This Question has 7 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on how are cell coordinates referenced on a clicked cell Or get search suggestion and latest updates.


Tagged: