Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm very new. How do you name a range? Like give a cell or range a name
rather than use "a1" cells(1,1). All I could find was this: ActiveWorkbook.Names.Add Name:="SecondTry", RefersToR1C1:= _ "=Sheet1!R8C2:R11C3" I got this by using record macro. I don't understand it. thanks John |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Range(Cells(1), Cells(4, 4)).Name = "NamedRange"
RBS "John" wrote in message ... I'm very new. How do you name a range? Like give a cell or range a name rather than use "a1" cells(1,1). All I could find was this: ActiveWorkbook.Names.Add Name:="SecondTry", RefersToR1C1:= _ "=Sheet1!R8C2:R11C3" I got this by using record macro. I don't understand it. thanks John |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I guess you don't understand the R1C1 format. R is the row and C is the
column. The name this is refering to is the worksheet names. The name of the range is "SecondTry" the range is Sheet1!B8:C11 You can also name a range in VBA as follows set MyRange = Range("A3:C7") or set MyRange = Range(cells(1,1), cells(5,5)) "John" wrote: I'm very new. How do you name a range? Like give a cell or range a name rather than use "a1" cells(1,1). All I could find was this: ActiveWorkbook.Names.Add Name:="SecondTry", RefersToR1C1:= _ "=Sheet1!R8C2:R11C3" I got this by using record macro. I don't understand it. thanks John |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Define what you mean by name a range and how you would use the name.
-- Regards, Tom Ogilvy "John" wrote: I'm very new. How do you name a range? Like give a cell or range a name rather than use "a1" cells(1,1). All I could find was this: ActiveWorkbook.Names.Add Name:="SecondTry", RefersToR1C1:= _ "=Sheet1!R8C2:R11C3" I got this by using record macro. I don't understand it. thanks John |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm writing a thing that solves soduku. At some point you have to guess
and try it. I want keep track of the cells I'm guessing. I wanted an array that holds all the guesses. I had CellTry() but what do you dim that if each one is going to be a named cell? I couldn't get it to work and gave up. It's easy enough just dim it CellTry(x,y) and save both coordinates. It would have been cooler to save it as one name though like try1, try2, try3 etc. John Tom Ogilvy wrote: Define what you mean by name a range and how you would use the name. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
try1 = Cells(i,j).Address(0,0)
Try1 will hold something like "B9" -- Regards, Tom Ogilvy "John" wrote: I'm writing a thing that solves soduku. At some point you have to guess and try it. I want keep track of the cells I'm guessing. I wanted an array that holds all the guesses. I had CellTry() but what do you dim that if each one is going to be a named cell? I couldn't get it to work and gave up. It's easy enough just dim it CellTry(x,y) and save both coordinates. It would have been cooler to save it as one name though like try1, try2, try3 etc. John Tom Ogilvy wrote: Define what you mean by name a range and how you would use the name. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
cool... what does the Address (0,0) mean?
John Tom Ogilvy wrote: try1 = Cells(i,j).Address(0,0) Try1 will hold something like "B9" |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
..address() has some parms that you can pass to it:
..address(rowabsolute:=false,columnabsolute:=false ) or ..address(rowabsolute:=0,columnabsolute:=0) or ..address(0,0) All do the same thing--they stop the corresponding $ signs from showing up in the address: $B$9 or $B9 or B$9 or B9 (depending on which parms are true or false) John wrote: cool... what does the Address (0,0) mean? John Tom Ogilvy wrote: try1 = Cells(i,j).Address(0,0) Try1 will hold something like "B9" -- Dave Peterson |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
John: I wrote a program that solves Sudoku puzzles a couple of years ago. I
used a recursive program that just tried every possible combination until the solution was found. It runs in about 5 seconds. Don't try to solve the puzzle the same way you would manually solve the puzzle, it is too complicated. "John" wrote: I'm writing a thing that solves soduku. At some point you have to guess and try it. I want keep track of the cells I'm guessing. I wanted an array that holds all the guesses. I had CellTry() but what do you dim that if each one is going to be a named cell? I couldn't get it to work and gave up. It's easy enough just dim it CellTry(x,y) and save both coordinates. It would have been cooler to save it as one name though like try1, try2, try3 etc. John Tom Ogilvy wrote: Define what you mean by name a range and how you would use the name. |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Interesting... i did exactly the same thing. Then I wanted to write a
real one, mostly to pratice using the vb/excel language which is new to me. john Joel wrote: John: I wrote a program that solves Sudoku puzzles a couple of years ago. I used a recursive program that just tried every possible combination until the solution was found. It runs in about 5 seconds. Don't try to solve the puzzle the same way you would manually solve the puzzle, it is too complicated. "John" wrote: I'm writing a thing that solves soduku. At some point you have to guess and try it. I want keep track of the cells I'm guessing. I wanted an array that holds all the guesses. I had CellTry() but what do you dim that if each one is going to be a named cell? I couldn't get it to work and gave up. It's easy enough just dim it CellTry(x,y) and save both coordinates. It would have been cooler to save it as one name though like try1, try2, try3 etc. John Tom Ogilvy wrote: Define what you mean by name a range and how you would use the name. |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I did my code using a 9 x 9 array. I copied the cells A1:I9 into the arrray
at the beginning of the program. Then output the results back into spreadsheet at the end of the programming. I added cell formating to the program by adding a border around the cells, change the column width, changed the row width. I also made the color of the text different for the number given and the number solved. the rest of the code was simple basic language features. "John" wrote: Interesting... i did exactly the same thing. Then I wanted to write a real one, mostly to pratice using the vb/excel language which is new to me. john Joel wrote: John: I wrote a program that solves Sudoku puzzles a couple of years ago. I used a recursive program that just tried every possible combination until the solution was found. It runs in about 5 seconds. Don't try to solve the puzzle the same way you would manually solve the puzzle, it is too complicated. "John" wrote: I'm writing a thing that solves soduku. At some point you have to guess and try it. I want keep track of the cells I'm guessing. I wanted an array that holds all the guesses. I had CellTry() but what do you dim that if each one is going to be a named cell? I couldn't get it to work and gave up. It's easy enough just dim it CellTry(x,y) and save both coordinates. It would have been cooler to save it as one name though like try1, try2, try3 etc. John Tom Ogilvy wrote: Define what you mean by name a range and how you would use the name. |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can name a range on the worksheet by highlighting the range to be
named (e.g., A1:D10), clicking on the down-arrow just above Column A, typing the name (e.g., myRange), and entering. You could then refer to the range in VBA as Range("myRange"); i.e., Range("myRange").Address would return $A$1:$D$10. You can also name a range in VBA with something like Range("A1:D10").Name = "myRange"; you could also refer to this range in VBA as Range("myRange"). You can also set an Object Variable to refer to the range; e.g., Set myRange = Range("A1:D10"). You could refer to this range in VBA with myRange; i.e., myRange.Address would return $A$1:$D$10. Alan Beban John wrote: I'm very new. How do you name a range? Like give a cell or range a name rather than use "a1" cells(1,1). All I could find was this: ActiveWorkbook.Names.Add Name:="SecondTry", RefersToR1C1:= _ "=Sheet1!R8C2:R11C3" I got this by using record macro. I don't understand it. thanks John |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I enter formula sum(range+range)*0.15 sumif(range=3) | Excel Discussion (Misc queries) | |||
Excel Addin:Setting the range to the Excel.Range object range prop | Excel Worksheet Functions | |||
Range Question / error 1004: method Range of object Worksheet has failed | Excel Programming | |||
Range.Find returns cell outside of range when range set to single cell | Excel Programming | |||
how to? set my range= my UDF argument (range vs. value in range) [advanced?] | Excel Programming |