Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is wrong with this code ??
Don't know why this code won't work
Trying to define array ("M1:O1") thru ("M5:O5") and input results to a child sheet The code below this and before the 'NEXT' statement works fine. For g = 1 to 5 Set gml = Sheets("Input").Range(cells(g,13),cells(g,15)) next Anyhelp is appreciated Chris |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is wrong with this code ??
Try setting the worksheet of the cells in the Range.
-- Disregard, this is so I can find my post later. ***postedbyJay*** "cgnotrom" wrote: Don't know why this code won't work Trying to define array ("M1:O1") thru ("M5:O5") and input results to a child sheet The code below this and before the 'NEXT' statement works fine. For g = 1 to 5 Set gml = Sheets("Input").Range(cells(g,13),cells(g,15)) next Anyhelp is appreciated Chris |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is wrong with this code ??
Maybe
Set gml = Sheets("Input").Range(Cells(1, 13), Cells(5, 15)) Mike "cgnotrom" wrote: Don't know why this code won't work Trying to define array ("M1:O1") thru ("M5:O5") and input results to a child sheet The code below this and before the 'NEXT' statement works fine. For g = 1 to 5 Set gml = Sheets("Input").Range(cells(g,13),cells(g,15)) next Anyhelp is appreciated Chris |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is wrong with this code ??
Dim G as long
dim gml as range with sheets("input") for g = 1 to 5 set gml = .range(.cells(g,13), .cells(g,15)) 'do something with gml here??? next g end with or for g = 1 to 5 set gml = sheets("sheet1").cells(g,13).resize(1,3) 'do something with gml here??? next g cgnotrom wrote: Don't know why this code won't work Trying to define array ("M1:O1") thru ("M5:O5") and input results to a child sheet The code below this and before the 'NEXT' statement works fine. For g = 1 to 5 Set gml = Sheets("Input").Range(cells(g,13),cells(g,15)) next Anyhelp is appreciated Chris -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is wrong with this code ??
Notice the placement of the dots in front of .range and .cells
Not quite sure what you want here. As shown, you get 1 in all 15 cells. Changing the comment to the next to last line gets you only 3 on row 5 Sub doit() For g = 1 To 5 With Sheets("Input") Set gml = .Range(.Cells(g, 13), .Cells(g, 15)) gml.Value = 1 End With Next 'gml.Value = 1 End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "cgnotrom" wrote in message ... Don't know why this code won't work Trying to define array ("M1:O1") thru ("M5:O5") and input results to a child sheet The code below this and before the 'NEXT' statement works fine. For g = 1 to 5 Set gml = Sheets("Input").Range(cells(g,13),cells(g,15)) next Anyhelp is appreciated Chris |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is wrong with this code ??
Thankyou Dave The second suggestion works great..the .resize comand did the trick and has saved me many 'if then' statements. Thanks again Chris "Dave Peterson" wrote: Dim G as long dim gml as range with sheets("input") for g = 1 to 5 set gml = .range(.cells(g,13), .cells(g,15)) 'do something with gml here??? next g end with or for g = 1 to 5 set gml = sheets("sheet1").cells(g,13).resize(1,3) 'do something with gml here??? next g cgnotrom wrote: Don't know why this code won't work Trying to define array ("M1:O1") thru ("M5:O5") and input results to a child sheet The code below this and before the 'NEXT' statement works fine. For g = 1 to 5 Set gml = Sheets("Input").Range(cells(g,13),cells(g,15)) next Anyhelp is appreciated Chris -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
What's wrong with this code? | Excel Programming | |||
What is wrong with my code?? | Excel Programming | |||
What is wrong with the code? | Excel Discussion (Misc queries) | |||
What is wrong with this code? | Excel Programming | |||
HELP! What's wrong with my code? | Excel Programming |