Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Please explain why following code doesn't work....

What I am trying to do is use an array to 'flip'
a sequence of numbers.

The code doesn't work :-(


Sub Panel_Flip()

Dim store(3) As Double
For i = 3 To 0
store(i)=ActiveCell.Offset(0,1+i).Value
Next

For i=0 to 3
ActiveCell.Offset(1,0).Value=store(i)
Next
End Sub


I need to know where I am going wrong...

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Please explain why following code doesn't work....

And change as well

Activecell.offset(1+i,0).value=store(i)

else you'd be writing the same cell all the time.


-----Original Message-----
Change

For i = 3 To 0
to
For i = 3 To 0 Step -1


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"FMNT80" wrote in message
. com...
What I am trying to do is use an array to 'flip'
a sequence of numbers.

The code doesn't work :-(


Sub Panel_Flip()

Dim store(3) As Double
For i = 3 To 0
store(i)=ActiveCell.Offset(0,1+i).Value
Next

For i=0 to 3
ActiveCell.Offset(1,0).Value=store(i)
Next
End Sub


I need to know where I am going wrong...

Thanks



.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Please explain why following code doesn't work....

Current Version: (Working)


Sub Panel_Flip()

Dim store(3) As Double
For i = 3 To 0 Step -1
void = MsgBox(i, vbOKOnly, "i:=")
store(i) = Val(ActiveCell.Offset(0, 1 + i).Value)
void = MsgBox(store(i), vbOKOnly, "Store(" + Str$(i) + ")")
Next

For i = 0 To 3
void = MsgBox(store(i), vbOKOnly, "Store(" + Str$(i) + ")")
ActiveCell.Offset(0, 4 - i).Range("A1").Value = store(i)
Next
End Sub


Now to extend it to a selection of any length (more complicated :-)).
I'm assuming Current Region plays a role.
Ideally it should be possible to have a routine tat will flip
even if your not at the start of the sequence but that would
need some way of determing the start and end columsn of a
selected region..

FMNT80
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Maco code doesn't work. Why? Joe M. Excel Discussion (Misc queries) 2 January 13th 10 07:13 PM
Why does this code not work? rk0909 Excel Discussion (Misc queries) 12 September 4th 08 10:42 PM
code does not work anymore Wanna Learn Excel Discussion (Misc queries) 2 July 24th 08 03:51 PM
Event code won't work marker68 Excel Discussion (Misc queries) 2 April 2nd 08 01:13 AM
Why this code is not work? Error code when select worksheet Excel Worksheet Functions 4 December 4th 07 12:51 AM


All times are GMT +1. The time now is 06:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"