Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Move from 1 section in a sheet to another

0

I hope I can explain this

make a sheet

in colume a to f  then down to row 10 make full page  make it red  call it A

then from g to k then down to 10 make it blue call it B

then from l to p then down to 10 make it green call it C

each section is full width of screen

I want to make a button on each section that can goto the next  section  like this

on section A  a button to goto section b

on section B to goto section B

On section C a button to goto section  A

By a macro or vba coding

Thank you

I hope I have made my self cleasr

Answer
Discuss

Answers

0
Selected Answer

Hello buildxp and welcome to the forum,

This can easily be done using VBA.

First you will need to resize the columns and rows so they fill the screen. These sizes will be specific to your computer based on its screen size and resolution. If you use the file on a different computer the column width and row height will need to be adjusted.

Your group A is 6 columns and groups B & C are 5 columns so column width for B & C will be wider. On my laptop the column widths are: group A – 23.56 and groups B & C – 28.56; the row height is 31. I added a row at the top as a header row and somewhere to put a button for the macros (height 30)

Three simple macros are used to switch between groups.

Sub Scroll_To_GroupB()

ActiveWindow.SmallScroll ToRight:=6
Range("G1").Select

End Sub
Sub Scroll_To_GroupC()

ActiveWindow.SmallScroll ToRight:=5
Range("L1").Select

End Sub
Sub Scroll_To_GroupA()

ActiveWindow.SmallScroll ToLeft:=12
Range("A1").Select

End Sub

I have attached a sample file to show how this would work.

UPDATE Dec. 8th

I have attached a second file (Go To Group A-B-C - Ver 2.xlsm) which does the row and column resize automatically. There is one small glitch - if on a blank default worksheet there is a partial row and/or column visible it will be included in the count of what is visible and the resize will be slightly "off". Here is the code placed in the "ThisWorkbook" code window:

Private Sub Workbook_Open()

Dim RH As Double   ' default height of rows on blank worksheet
Dim NewH As Double   ' height to resize rows 1 to 11 to
Dim CW As Double   ' default width of columns on blank worksheet
Dim NewW1 As Double   ' width to resize columna A to F to
Dim NewW2 As Double   ' width to resize columna G to P to
Dim VisR As Long   ' number of rows visible on blank worksheet in the window
Dim Visc As Long   ' number of columns visible on blank worksheet in the window

' unprotect workbook (if protected)
'ActiveWorkbook.Unprotect "your password"

Application.ScreenUpdating = False

' add a worksheet to get default row and column sizes from
Sheets.Add.Name = "Test"

' get default row height and calculate new height for rows 1 to 11
VisR = ActiveWindow.VisibleRange.Rows.Count
RH = Rows(1).RowHeight
NewH = VisR * RH / 11
' get default column width and calculate new width for group "A" and for "B" & "C"
Visc = ActiveWindow.VisibleRange.Columns.Count
CW = Columns(1).ColumnWidth
NewW1 = Visc * CW / 6   ' group "A"
NewW2 = Visc * CW / 5   ' group "B" & "C"
' resize rows 1 to 11 and columns "A" thru "P"
Sheets("Data").Select
Rows("1:11").RowHeight = NewH
Columns("A:F").ColumnWidth = NewW1   ' group "A"
Columns("G:P").ColumnWidth = NewW2   ' group "B" & "C"

' delete the added worksheet ("Test")
Application.DisplayAlerts = False
Sheets("Test").Delete
Application.DisplayAlerts = True

Application.ScreenUpdating = True

' reprotect workbook (if needed)
'ActiveWorkbook.Protect "your password"

' save the workbook
ActiveWorkbook.Save

End Sub

If this solves your question please mark my answer as Selected.

Cheers   :-)

Discuss

Discussion

@Willie - nice work. One minor thing- the button over cell HI reads "Go To Group B" but should read "Go To Group C" to match the action on clicking it..
John_Ru (rep: 6142) Dec 8, '23 at 3:57 am
Thank you so much for the file and information.
As a new person to excell it is a bit mind blowing
I have done my simple spreadsheet now and works
The only thing did not understand was about
First you will need to resize the columns and rows so they fill the screen. These sizes will be specific to your computer based on its screen size and resolution. If you use the file on a different computer the column width and row height will need to be adjusted.

So if i use it on another computer I will have to alter it all?

Many thanks
buildxp (rep: 2) Dec 8, '23 at 4:53 am
@John
Nice catch; copy-paste got me again. (lol) I have made the correction and replaced the file with the corrected version.

@buildxp

A computer's physical screen size and resolution setting control how much is seen on screen. I have a file with 37 rows and 210 columns that I use on both my laptop and my desktop. On my laptop, 22 rows and 27 columns are visible; on my desktop 40 rows and 39 columns are visible.
So the column width and row height you use on one computer will need to be different on another computer. (unless, of course, the other computer has the same screen resolution and physical size)
It is possible to write a macro to use in the Workbook_Open event but that gets somewhat complex. It requires knowing the screen resolution of the computer on which the file was created. The code would then check the screen resolution of the other computer and compare that to the original and adjust row hieght and column width accordingly. But this is not guaranteed because the physical size of the screen also plays a role but is not part of the comparison.

Cheers   :-)
WillieD24 (rep: 557) Dec 8, '23 at 9:03 am
@Willie - thanks for correcting your file. On screen resolution, you could  capture it and adjust
or instead (from memory!) use something like:
ActiveWindow.Columns(8)
ActiveWindow.SmallScroll ToLeft:=0

to jump to colum H (8) say but...

@buildxp - given you're new to Excel, please accept that Willie has answered your question (with a fairly sophisticated solution). Your job now is to reward him simply by marking his Answer as Selected. After that , perhaps head to the Tutorials section (link above) to learn lots!
John_Ru (rep: 6142) Dec 8, '23 at 11:13 am
@buildxp

See my update above - Dec. 8th
The Ver 2 file does the row/column resizing automatically.

Cheers   :-)
WillieD24 (rep: 557) Dec 8, '23 at 4:48 pm
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login