![]() |
Dim cell AS range....
I would like to understand this..lets see if i understand
what it is telling vb to do. .... Dim cell As Range, rng AS Range Dim rng1 As Range .... this is part of the whole code i have but i was thinking of this part... Does this mean that it is setting a "cell" as a range in the whole workbook and when it sees what it is looking for in that cell then that cell is referred to as rng1 for the moment? can anyone clarify and tell me if i am close or in the outfield? mike |
Dim cell AS range....
Mike,
All that code is doing is declaring three variables as Range type objects. These variables don't refer to any range or cell in particular. They can be set to a specific cell or range of cells with the Set command. For example, Dim Rng1 As Range Dim Rng2 As Range Set Rng1 = Range("A1") Set Rng2 = Cells.Find("abc") If you attempt to use any of the variables without initializing them with a Set command, you'll receive an error 91 - Object Variable Not Set. Unless you specifically set the variable to a particular range, it doesn't refer to any range. There is nothing automatic going on. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "mike" wrote in message ... I would like to understand this..lets see if i understand what it is telling vb to do. ... Dim cell As Range, rng AS Range Dim rng1 As Range ... this is part of the whole code i have but i was thinking of this part... Does this mean that it is setting a "cell" as a range in the whole workbook and when it sees what it is looking for in that cell then that cell is referred to as rng1 for the moment? can anyone clarify and tell me if i am close or in the outfield? mike |
Dim cell AS range....
Hi
this code part is just the variable declaration. It tells VBA which type of variable 'rng' or 'cell' are (you can replace these names with whatever name you like) Another example would be: Dim Str as String this tells VBA what Str is a string variable. You may take a look at the following website to learn more about VBA: http://www.mvps.org/dmcritchie/excel/getstarted.htm -- Regards Frank Kabel Frankfurt, Germany mike wrote: I would like to understand this..lets see if i understand what it is telling vb to do. ... Dim cell As Range, rng AS Range Dim rng1 As Range ... this is part of the whole code i have but i was thinking of this part... Does this mean that it is setting a "cell" as a range in the whole workbook and when it sees what it is looking for in that cell then that cell is referred to as rng1 for the moment? can anyone clarify and tell me if i am close or in the outfield? mike |
Dim cell AS range....
Mike,
All that code is doing is defining three variables, all of range datatype. In itself, it does nothing, each variable is nothing at that point, but worksheets ranges can be loaded (set cell = Range("A1")) and then used in any subsequent processing. AT this point they also have no relationship to one another. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "mike" wrote in message ... I would like to understand this..lets see if i understand what it is telling vb to do. ... Dim cell As Range, rng AS Range Dim rng1 As Range ... this is part of the whole code i have but i was thinking of this part... Does this mean that it is setting a "cell" as a range in the whole workbook and when it sees what it is looking for in that cell then that cell is referred to as rng1 for the moment? can anyone clarify and tell me if i am close or in the outfield? mike |
All times are GMT +1. The time now is 10:17 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com