Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to duplicate a value from a cell to another cell, and then move
down a cell and copy into that cell aswell, taking into acount that counter1 0; Heres the code; counter1 = Range("L6") contenta1 = Range("m6") linenumb = 19 If counter1 0 Then linenumb = linenumb + 1 Range("m" & linenumb).Select ActiveCell.Value = Range("m6") Range("l" & counter1).Select ActiveCell.Value = counter1 counter1 = counter1 - 1 Else End If It doesnt do what I need it to do, and I think I must be having a blonde moment because I can't see what;s wrong. Can anyone help me please Thanks in advance for all and any help Steve |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Have you tried using the debugger and tracing through your code?
"Steve" wrote: I am trying to duplicate a value from a cell to another cell, and then move down a cell and copy into that cell aswell, taking into acount that counter1 0; Heres the code; counter1 = Range("L6") contenta1 = Range("m6") linenumb = 19 If counter1 0 Then linenumb = linenumb + 1 Range("m" & linenumb).Select ActiveCell.Value = Range("m6") Range("l" & counter1).Select ActiveCell.Value = counter1 counter1 = counter1 - 1 Else End If It doesnt do what I need it to do, and I think I must be having a blonde moment because I can't see what;s wrong. Can anyone help me please Thanks in advance for all and any help Steve |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You should probably be using a while loop, sort of like the following.
(I also modified it so to Range("l" & linenumb).Select instead of using counter1. counter1 = Range("L6") contenta1 = Range("m6") linenumb = 19 While counter1 0 linenumb = linenumb + 1 Range("m" & linenumb).Select ActiveCell.Value = Range("m6") Range("l" & linenumb).Select ActiveCell.Value = counter1 counter1 = counter1 - 1 Wend You can also do the following: counter1 = Range("L6") contenta1 = Range("m6") linenumb = 19 While counter1 0 linenumb = linenumb + 1 Range("m" & linenumb) = contenta1 Range("l" & linenumb) = counter1 counter1 = counter1 - 1 Wend Scott Steve wrote: I am trying to duplicate a value from a cell to another cell, and then move down a cell and copy into that cell aswell, taking into acount that counter1 0; Heres the code; counter1 = Range("L6") contenta1 = Range("m6") linenumb = 19 If counter1 0 Then linenumb = linenumb + 1 Range("m" & linenumb).Select ActiveCell.Value = Range("m6") Range("l" & counter1).Select ActiveCell.Value = counter1 counter1 = counter1 - 1 Else End If It doesnt do what I need it to do, and I think I must be having a blonde moment because I can't see what;s wrong. Can anyone help me please Thanks in advance for all and any help Steve |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you very much
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to set up countdown timer to countdown days to a specific day | Excel Worksheet Functions | |||
select range and put range address in variable | Excel Programming | |||
Macro to copy a specified range to a variable range | Excel Programming | |||
setting a range variable equal to the value of a string variable | Excel Programming | |||
Problem trying to us a range variable as an array variable | Excel Programming |