| | |
Basic Variables Question
Thread Solved |
•
•
Join Date: Jul 2006
Posts: 2
Reputation:
Solved Threads: 0
Hello. This is a very very basic question about variables in range names.
I have quite a few ranges of varying lengths in multiple Excel documents. I want all the ranges standardized and set to the same length, but I don't know what that length will be yet, and it may change, so I'd like to make a variable for it.
This is currently the best I've come up with:
I have quite a few ranges of varying lengths in multiple Excel documents. I want all the ranges standardized and set to the same length, but I don't know what that length will be yet, and it may change, so I'd like to make a variable for it.
This is currently the best I've come up with:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Sub FixEverything() Dim sh As Worksheet For Each sh In Worksheets sh.Visible = True Next Dim OutLim As Integer OutLim = 200 ActiveSheet.Names.Add Name:="RangeNameHere", RefersTo:="=$A$3:$B$OutLim" ' One of these lines per named Array Worksheets(2).Visible = Hide Worksheets(4).Visible = Hide Worksheets(6).Visible = Hide Worksheets(8).Visible = Hide End Sub
Hi
Are you working with multiple excel documents or with multiple worksheets in the same document. I guess it does not really matter.
i noticed you have an error in your formula, if you want to set a range the worksheets of your workbook do something like this:
that will set the range A3:B200 in the first three sheets.
If you want to do it in all the sheets, do as you did at the beginning: for each sh in workbooks
regards
Are you working with multiple excel documents or with multiple worksheets in the same document. I guess it does not really matter.
i noticed you have an error in your formula, if you want to set a range the worksheets of your workbook do something like this:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
For i = 1 To 3 OutLim = 200 Worksheets(i).Activate ActiveSheet.Names.Add Name:="RangeNameHere", RefersTo:="=$A$3:$B$" & OutLim Next
that will set the range A3:B200 in the first three sheets.
If you want to do it in all the sheets, do as you did at the beginning: for each sh in workbooks
regards
![]() |
Similar Threads
- VBscript in a Visual Basic Application (Visual Basic 4 / 5 / 6)
- Basic SQL question! (MS SQL)
- Basic Access Question (MS Access and FileMaker Pro)
- Basic scripting question (Getting Started and Choosing a Distro)
- What language to start with (Computer Science)
- How can i deledet and update from table ??????? (PHP)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: URgent help
- Next Thread: Quickbasic 4.5
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





