Macro to add to or subtract from identified row numbers in multiple macros

tectonicseer

New Member
Joined
Jul 22, 2014
Messages
1
I have a spreadsheet that, when prompted by a list box, will hide or unhide rows in specified groupings. I will need to add and delete a few more rows throughout this list and by doing so will make the VBA script (sample below) non-functional (by "pointing" at the wrong rows). This script is repeated about 24-30 times covering approximately 700 rows. These groupings are sequential and do not overlap one another.

Question: is there a macro I can use to automatically renumber a range of rows by a certain +/- value, and then another range with a different value?

Thanks for your insights! David
Code:
Sub ProcessSheet1ChangeOnCellJ7(ByVal Target As Range)


  Dim sAddress As String
  Dim sValue As String
  
  'Get the address of the cell that changed without '$' signs
  sAddress = Target.Address(False, False)
  
  'Get the value in the cell without leading and trailing spaces
  'Allow processing to continue if the cell does not contain text
  On Error Resume Next
  sValue = Trim(Target.Value)
  On Error GoTo 0


  'Perform 'J7' only processing
  If sAddress = "J7" Then
    ' HIDE ROWS IN TASKS WORKSHEET BASED ON USER SELECTION
    If Target.Value = "Not Pursuing" Then
        ActiveWorkbook.Sheets("Tasks").Rows("29:29").EntireRow.Hidden = False
        ActiveWorkbook.Sheets("Tasks").Rows("30:48").EntireRow.Hidden = True
    ElseIf Target.Value = "Pursuing - Show All Tasks" Then
        ActiveWorkbook.Sheets("Tasks").Rows("29:29").EntireRow.Hidden = True
        ActiveWorkbook.Sheets("Tasks").Rows("30:48").EntireRow.Hidden = False
    Else
        'This branch of code should NEVER be selected.
        MsgBox "SOFTWARE INTEGRITY ERROR.  Illegal selection on:" & vbCrLf & _
               "Sheet 'Tasks'" & vbCrLf & _
               "Cell: '" & sAddress & "'" & vbCrLf & _
               "Value: '" & sValue & "'"
        Stop
    End If
  End If
    
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top