VBA move to next available row

blossomthe2nd

Active Member
Joined
Oct 11, 2010
Messages
450
Hi Guys

Much to the help of previous queries I wrote a VBA code that shows certain columns dependant on value in cell B1, see below :

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If InStr("out_of_course drawdowns customer_service", LCase(Range("B1").Value)) > 0 Then
Columns("C:G").EntireColumn.Hidden = True
Else
Columns("C:G").EntireColumn.Hidden = False
End If
If InStr("rollovers", LCase(Range("B1").Value)) > 0 Then
Columns("i:K").EntireColumn.Hidden = True
Else
Columns("i:K").EntireColumn.Hidden = False
End If
If InStr("out_of_course drawdowns rollovers", LCase(Range("B1").Value)) > 0 Then
Columns("L:N").EntireColumn.Hidden = True
Else
Columns("L:N").EntireColumn.Hidden = False
End If
If InStr("customer_service drawdowns rollovers", LCase(Range("B1").Value)) > 0 Then
Columns("O:q").EntireColumn.Hidden = True
Else
Columns("O:q").EntireColumn.Hidden = False
End If
If InStr("customer_service rollovers", LCase(Range("B1").Value)) > 0 Then
Columns("R").EntireColumn.Hidden = True
Else
Columns("R").EntireColumn.Hidden = False
End If
If InStr("customer_service rollovers out_of_course", LCase(Range("B1").Value)) > 0 Then
Columns("s:Z").EntireColumn.Hidden = True
Else
Columns("s:Z").EntireColumn.Hidden = False
End If
If InStr("rollovers drawdowns", LCase(Range("B1").Value)) > 0 Then
Columns("h").EntireColumn.Hidden = True
Else
Columns("h").EntireColumn.Hidden = False
End If
End Sub

My problem is , this is for a type of Form , so in the worksheet I have frozen the column header to row 2.

What I would like to happen is after the above columns have been hidden the curser will go to the next available row and (if possible ) move this row up directly beneath the frozen headers !!

Can anyone help ?
 
Thanks Andrew,

Out of curiosity why wouldn't you reccommend Sharing?

This is a log of activities that a team completes, they fill out the excel work book throughout the day , but many users would use the same log ,

Is there a better way to do this ?

Thanks

Anne
 
Upvote 0

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