Hi. I have a very handy code that someone on this forum was kind enough to write for me. The code automatically hides columns based on user input. It works perfectly. I type a number (1-10) into a cell, and then depending on the number, a corresponding number of columns hide.
The issue is, when i type anything in any of the last couple of columns (the columns that are off-screen and I need to scroll over to the right to see - columns H-L), after inputting anything into any cell within that column, Excel brings me way far over to the far right, well past any visible columns and I have to scroll back over to input the next cell of data.
I'd like the screen view to stay on whatever column I am working within. Here is the code:
Workbook:
Private Sub Workbook_Open()
Dim C6 As Range
With Worksheets("Submission Form")
Set C6 = .Range("C6")
.Columns("D").Resize(, Columns.Count - 3).Hidden = True
C6.Select
If IsNumeric(C6.Value) And Len(C6.Value) > 0 Then
If C6 > 1 And C6 < 11 Then Columns("D").Resize(, C6 + (C6 > 1)).Hidden = False
End If
End With
End Sub
Worksheet:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim C6 As Variant
C6 = Range("C6").Value
If IsNumeric(C6) And Len(C6) > 0 Then
Columns("D:L").Hidden = True
If C6 > 1 And C6 < 11 Then Columns("D").Resize(, C6 + (C6 > 1)).Hidden = False
End If
End Sub
Any suggestions on how to modify?
Thanks in advance!!
The issue is, when i type anything in any of the last couple of columns (the columns that are off-screen and I need to scroll over to the right to see - columns H-L), after inputting anything into any cell within that column, Excel brings me way far over to the far right, well past any visible columns and I have to scroll back over to input the next cell of data.
I'd like the screen view to stay on whatever column I am working within. Here is the code:
Workbook:
Private Sub Workbook_Open()
Dim C6 As Range
With Worksheets("Submission Form")
Set C6 = .Range("C6")
.Columns("D").Resize(, Columns.Count - 3).Hidden = True
C6.Select
If IsNumeric(C6.Value) And Len(C6.Value) > 0 Then
If C6 > 1 And C6 < 11 Then Columns("D").Resize(, C6 + (C6 > 1)).Hidden = False
End If
End With
End Sub
Worksheet:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim C6 As Variant
C6 = Range("C6").Value
If IsNumeric(C6) And Len(C6) > 0 Then
Columns("D:L").Hidden = True
If C6 > 1 And C6 < 11 Then Columns("D").Resize(, C6 + (C6 > 1)).Hidden = False
End If
End Sub
Any suggestions on how to modify?
Thanks in advance!!