Hi there
I am using SPIN button (SB2) to scroll through the excel sheet table. Data of filtered rows is also being displayed in text boxes (please see code below)
Issue is I want to scroll through only the visible rows. with the code it is checking every row (i.e. 1.2.3...)- instead I would like to have in such a way that spinbox scroll only visible rows i.e 1, 4, 7 (as only rows 1, 4 and 7 are visibile after applying filters)
Thanks in advance
Private Sub SB2_Change()
'SB2 is name of Spin button
SB2.Min = 2 'defining minimum value. Row 1 is header
CellNr = SB2.Value
If ActiveWorkbook.Sheets("Sheet1").Range("a" & CellNr) = "" Then
MsgBox "you have reached the end of record"
TextBox4.Text = "End of record"
TextBox5.Text = "End of record"
' getting the data of visibile rows only on text box
ElseIf ThisWorkbook.Sheets("sheet1").Rows(CellNr).Hidden = False Then
TextBox6.Text = SB2.Value
TextBox4.Text = ActiveWorkbook.Sheets("Sheet1").Range("A" & CellNr).Value
TextBox5.Text = ActiveWorkbook.Sheets("Sheet1").Range("b" & CellNr).Value
End If
End Sub
I am using SPIN button (SB2) to scroll through the excel sheet table. Data of filtered rows is also being displayed in text boxes (please see code below)
Issue is I want to scroll through only the visible rows. with the code it is checking every row (i.e. 1.2.3...)- instead I would like to have in such a way that spinbox scroll only visible rows i.e 1, 4, 7 (as only rows 1, 4 and 7 are visibile after applying filters)
Thanks in advance
Private Sub SB2_Change()
'SB2 is name of Spin button
SB2.Min = 2 'defining minimum value. Row 1 is header
CellNr = SB2.Value
If ActiveWorkbook.Sheets("Sheet1").Range("a" & CellNr) = "" Then
MsgBox "you have reached the end of record"
TextBox4.Text = "End of record"
TextBox5.Text = "End of record"
' getting the data of visibile rows only on text box
ElseIf ThisWorkbook.Sheets("sheet1").Rows(CellNr).Hidden = False Then
TextBox6.Text = SB2.Value
TextBox4.Text = ActiveWorkbook.Sheets("Sheet1").Range("A" & CellNr).Value
TextBox5.Text = ActiveWorkbook.Sheets("Sheet1").Range("b" & CellNr).Value
End If
End Sub