ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Limiting a macro to one column (https://www.excelbanter.com/excel-discussion-misc-queries/14203-limiting-macro-one-column.html)

Steve

Limiting a macro to one column
 
Sorry, that sounds really wierd, but what I want to do is this:

I have a data table of around 2000 rows and 16 columns. I want to have
a 'Delete Selected Row' button. The idea is that the selected cell and
the 15 to the right of it are cleared. I have the following code:

ActiveCell.Value = ""
ActiveCell.Offset(0, 1).Value = ""
....
ActiveCell.Offset(0, 15).Value = ""

Any cell in the table can be selected for amendment ,but how can I
amend the Button's code so that it only works if the ActiveCell is in
column B?

Thanks in advance.

Steve


JE McGimpsey

one way:

With ActiveCell
If .Column = 2 Then .Resize(1, 15).ClearContents
End With

In article . com,
"Steve" wrote:

Sorry, that sounds really wierd, but what I want to do is this:

I have a data table of around 2000 rows and 16 columns. I want to have
a 'Delete Selected Row' button. The idea is that the selected cell and
the 15 to the right of it are cleared. I have the following code:

ActiveCell.Value = ""
ActiveCell.Offset(0, 1).Value = ""
...
ActiveCell.Offset(0, 15).Value = ""

Any cell in the table can be selected for amendment ,but how can I
amend the Button's code so that it only works if the ActiveCell is in
column B?

Thanks in advance.


Steve

.... now you're just making this look easy.

That's perfect. Thanks a lot.

S:)


Dave Peterson

Maybe you could just use the row that the activecell is on???

cells(activecell.row,2).resize(1,15).clearcontents

Just a thought.

Steve wrote:

... now you're just making this look easy.

That's perfect. Thanks a lot.

S:)


--

Dave Peterson


All times are GMT +1. The time now is 08:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com