I am working on simplifying a worksheet by creating one sheet that has three buttons instead of having three tabs to view.
Here is the workbook.
https://dl.dropbox.com/u/3327208/Excel/Archives.xlsx
What I am attempting to do is this, each button corresponds to a specific tab, it will ultimately adjust each field to fit each corresponding column in each tab. Since Archive 1 needs a different format than Archive 2 or 3.
Now this would be a simple Copy and paste concept, but what I want to have done are two things that makes this a little more complex than a basic script because I can create a script that deletes columns, and pastes data into cells but I will be using a scroll bar, and that can’t as far as I can tell be deleted by the same commands or can it? This is what I’m looking for…
– How to create a scroll bar, with all data corresponding to it so it
will work with said active data, so if I push the first button all
data on the screen will correspond to Archive 1, and so will the
scroll bar. If I push button 2, the data and scroll bar will
correspond to Archive 2, etc…
-
Have it so that the number of related rows the scroll bar
interacts with will always correspond to the last row, so there is no
“empty” data at the end when the scroll bar hits the bottom. -
How to delete said scroll bar as well so it can be replaced by others.
– This is a want, not a need, but make it so the cells that the data is entered to interact with the scroll bar, and the scroll bar
will only go so far down as the height of the visible worksheet. So
in English if the worksheet shows 20 rows, that is how far the bar
and the data will go.
Thanks again.
I’ve decided to try using the lastrow concept to make it so that the script will enter the “lastrow” into the .Max for the scroll bar will go no further than the last row of data, here is the code:
Sub scrollbar()
Dim lastrow As Long
Dim wsJAR As Worksheet 'JL Archive
Dim wsARC As Worksheet 'JL Archive
Set wsJAR = Sheets("JL Archive")
Set wsARC = Sheets("Archives")
With wsARC
lastrow = wsJAR.Range("B" & .Rows.Count).End(xlUp).Row
ActiveSheet.ScrollBars.Add(1107, 44, 15, 404).Select
With Selection
.Max = lastrow
.LinkedCell = "Lists!$G$3"
End With
End With
End Sub
There are no errors, it’s accepting lastrow as a number, but in continues past the cell even though there is no reason for it to do so.
The last row is 36, now if I take off 13, from 36 it works perfectly, but I can’t imagine that is the answer.
Change
to
FINAL CODE