Conditional scrolling macro

Hart

Board Regular
Joined
Jan 2, 2005
Messages
71
Hi all.
I would like to create a macro which would scroll through a table if there are too many rows to fit on the display. For example, if the table had more than 25 rows, scroll until the last row is displayed. Once the end of the table is reached, the scroll would return to the first entry in the table and repeat.
If the table had <= 25 rows, no scrolling is required.
Something like:
if rows(table1)<=25 then no scroll
else scroll to end of table (and repeat)

Thanks!
 
Run this code (any module will do) - should return true

Code:
Sub ee()
MsgBox Application.EnableEvents
End Sub
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
After this line
Code:
Set tbl = Target.ListObject

add this line
Code:
msgbox tbl.name

Select any cell in the table and the message box containing table name should appear
 
Upvote 0
I should have been more specific...
No - add the line to the Selection_Change macro
 
Upvote 0
It says "Table2"
That proves that you put the code in the correct place
It also proves that the table exists and is recognised as such
Now I need to work out why the scroll is not working for you when it does for me:confused:

Can you try all versions of the code
- delete the VBA each time and then paste in the others one at a time and test them
- include the message box - at least we then know that the code is being triggered
- let me know how you get on

I will be away for about 60 minutes
- if it is still not working for you, I will send you various code snippets to see if we can unravel the mystery :confused:
 
Last edited:
Upvote 0
Hi Yongle. The 2nd and 3rd pieces of code give the table name. The first piece of code does not work. I noted that there was an "end sub" that was outside the code window which I tried adding but it still did not compile. Syntax is not my strong point!
 
Upvote 0
Hi Yongle. The 2nd and 3rd pieces of code give the table name. The first piece of code does not work. I noted that there was an "end sub" that was outside the code window which I tried adding but it still did not compile. Syntax is not my strong point!

I will offline now for about 3-4 hrs. Thanks for all your help to this point.
Hart
 
Upvote 0

Forum statistics

Threads
1,217,401
Messages
6,136,410
Members
450,010
Latest member
Doritto305

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