•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 422,984 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,958 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 1712 | Replies: 2 | Solved
![]() |
•
•
Join Date: Jul 2006
Posts: 2
Reputation:
Rep Power: 0
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:
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:
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
![]() |
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
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 and Software Design)
- 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


Linear Mode