Multipage Form, "missing" correct Sheet reference

ebea

Board Regular
Joined
Jul 12, 2008
Messages
217
Office Version
  1. 2013
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

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
6,527
Office Version
  1. 2019
Platform
  1. Windows
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
 
Solution

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
23,992
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?
 

ebea

Board Regular
Joined
Jul 12, 2008
Messages
217
Office Version
  1. 2013
Platform
  1. Windows
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 ;)
 

ebea

Board Regular
Joined
Jul 12, 2008
Messages
217
Office Version
  1. 2013
Platform
  1. Windows
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.
 

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
6,527
Office Version
  1. 2019
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,130,295
Messages
5,641,398
Members
417,208
Latest member
wendy823

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
Top