Multipages 5 pages - 5 times code?

Bandito1

Board Regular
Joined
Oct 18, 2018
Messages
239
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

Im using this multipage on my forum.
I got 5 pages

Each page looks exact the same and is used to register mistakes.

Each page contains several checkboxes.
For example; chbCorrectby

Now due to ambiguous name restriction they are alle called differently; chbCorrectby1, chbCorrectby2, chbCorrectby3
The number corresponds with the page number.

Now my question;

Do i need to make code eacht time 5 times; see example below;
Or is there an easier / nicer way?

As said it's not only 1 checkbox, got more of them so the code below i have to do lot of times for the other checkboxes

VBA Code:
rivate Sub chbCorrectby_Click()
If chbCorrectby.Value = True Then
txtCorrectBy.Value = "N/A"
Else
txtCorrectBy.Value = ""
End If
End Sub

Private Sub chbCorrectby2_Click()
If chbCorrectby2.Value = True Then
txtCorrectBy2.Value = "N/A"
Else
txtCorrectBy2.Value = ""
End If
End Sub

Private Sub chbCorrectby3_Click()
If chbCorrectby3.Value = True Then
txtCorrectBy3.Value = "N/A"
Else
txtCorrectBy3.Value = ""
End If
End Sub

Private Sub chbCorrectby4_Click()
If chbCorrectby4.Value = True Then
txtCorrectBy4.Value = "N/A"
Else
txtCorrectBy4.Value = ""
End If
End Sub

Private Sub chbCorrectby5_Click()
If chbCorrectby5.Value = True Then
txtCorrectBy5.Value = "N/A"
Else
txtCorrectBy5.Value = ""
End If
End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Played some around with tab strip but i don't think this is it.

Lets say textbox1 on page 1 contains other data then textbox1 on page 2.
The pages look the same but can contain other data.

I want to register the data in my spreadsheet.

Seems like with strip all the textboxes are the same?
So no seperate data to register?
 
Upvote 0
So when I use a TabStrip the controls (objects) are constant throughout all the tabs.

The data that is filled in can differ and is stored on a worksheet.
I don't see how that is possible with TabStrip

Don't see how i can reduce the code by using TabStrip if i get many textboxes that are named differently
 
Upvote 0
Write the data to a sheet when you switch tabs on the tab strip and then read it back in when the relevant tab is clicked. That way you’re using one set of controls and saving data in worksheet rows between “tabs”
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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