Help to simplify code.

  • Thread starter Michael Beckinsale
  • Start date
M

Michael Beckinsale

Hi,

I have a spreadsheet where l need to call a macro when a particular cell is
changed. There are approx 100 cells (not adjacent) where l need to trigger
the macro. They are all on the same worksheet.

In the following example l have written If statements for 3 of the cells.

Obviously l do not want to write IF statements for all 100 instances.

Can somebody tell me what the code is to effectively list all the cells that
will trigger the IF statement and thus write only 1 IF statement ?

All suggestions warmly received.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

If Target.Address(False, False) = "B9" Then
Call AutoFitMergedCellRowHeight
End If

If Target.Address(False, False) = "F9" Then
Call AutoFitMergedCellRowHeight
End If

If Target.Address(False, False) = "B14" Then
Call AutoFitMergedCellRowHeight
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top