Multipage Form, "missing" correct Sheet reference

ebea

Active Member
Joined
Jul 12, 2008
Messages
296
Office Version
  1. 2021
Platform
  1. Windows
Hi! I have a frustrating "little" problem, with a mulipage Form, that's when I switch between the Tabs, can't get the correct Sheet to list info, into Text boxes on the actual Tab. No matter which Tabs I select, it only list info from the first Tabs Sheet info.
I use the following code, to list through a list of numbers, which shows up in Text boxes. All that works correct, with exception, that the Sheet reference do not follow, even that I define "Set" Sheet in the code.

Sub spn4(x As Integer)
Dim Rng As Range
Static c As Integer
Set Sh = Sheets("samling")
Set Rng = Range(Range("B3"), Range("B" & Rows.Count).End(xlUp))
c = c + x
If c >= Rng.Count Then c = Rng.Count
If c <= 0 Then c = 1
TextBox65 = Rng(c)
Call CommandButton9_Click
End Sub

Private Sub SpinButton4_SpinDown()
Dim p As Integer
p = -1
Call spn4(p)
End Sub

Private Sub SpinButton4_SpinUp()
Dim p As Integer
p = 1
Call spn4(p)
End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi,
I suspect you need to qualify your range to resolve the issue - maybe.

Rich (BB code):
Set sh = Sheets("samling")
Set Rng = sh.Range(sh.Range("B3"), sh.Range("B" & sh.Rows.Count).End(xlUp))

Dave
 
Upvote 0
Solution
You code is putting the value of Range("B3").Cells(c, 1) into TextBox65.

There is nothing there that depends on which tab of a MultiPage is active.

What do you want to happen?
 
Upvote 0
Hi,
I suspect you need to qualify your range to resolve the issue - maybe.

Rich (BB code):
Set sh = Sheets("samling")
Set Rng = sh.Range(sh.Range("B3"), sh.Range("B" & sh.Rows.Count).End(xlUp))

Dave
That did the "trick". Thank you. I did try other combinations, to define the Sheet, without luck, but not this one ;)
 
Upvote 0
You code is putting the value of Range("B3").Cells(c, 1) into TextBox65.

There is nothing there that depends on which tab of a MultiPage is active.

What do you want to happen?
Thank's for taking the time, Mike. Yes, it's correct that it loads into TextBox65, but longer down in code, it calls CommandButton9, which runs rest of the code.
 
Upvote 0
That did the "trick". Thank you. I did try other combinations, to define the Sheet, without luck, but not this one ;)

welcome - glad we were able to help

Dave
 
Upvote 0

Forum statistics

Threads
1,214,879
Messages
6,122,065
Members
449,064
Latest member
scottdog129

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