Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VB Code Corrected Solutions

Hi, thanks everyone (especially Tom Ogilvy) for all your help much
appreciated.
The following is the original answer and 2 of the solutions i was
given.

my Current code was:

Range ("B9").Select
Dim i As Integer
For i = 4 to 7
ActiveCell.FormulaR1C1 = "R[-i]C[4]"
Next i
End Sub

And the following two solutions work:
Solution 1 displays each answer before it moves on.
Solution 2 is very simple. In the end I will by adding these values
(Solution3 given below) but only if each row meets a criteria (solution
not given here yet)


Sub Solution1()
Range("B9").Select
Dim i As Integer
For i = 4 To 7
ActiveCell.FormulaR1C1 = "=R[" & -i & "]C[4]"
ActiveCell.Value = ActiveCell.Value
MsgBox "Value in B9 is " & ActiveCell.Value & vbNewLine & _
"Value came from " & Range("B9").Offset(-i, 4).Address(0, 0, xlA1)
Next i
End Sub


Sub Solution2()
Dim iMyRow As Integer
For iMyRow = 2 To 5
Cells(9, 2) = Cells(iMyRow, 6)
Next
End Sub

Sub Solution3()
Dim iMyRow As Integer
Dim memory1 As Integer
Dim memory2 As Integer
memory2 = 0
For iMyRow = 2 To 5
Cells(9, 2) = Cells(iMyRow, 6)
mem = Cells(9, 2).Value
memory2 = memory2 + memory1
Next
Cells(9, 2) = memory2
End Sub

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
Combining columns corrected jezzica85 Excel Discussion (Misc queries) 2 March 11th 06 12:23 PM
IF AND question corrected Lee Excel Worksheet Functions 3 May 30th 05 01:12 AM
Array formula reference (Corrected) JAK Excel Discussion (Misc queries) 3 February 22nd 05 03:38 AM
Time events to trigger VB (corrected) David Robinson[_3_] Excel Programming 6 November 19th 03 02:06 PM
corrected formulas Steve[_29_] Excel Programming 0 August 12th 03 09:09 PM


All times are GMT +1. The time now is 04:35 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"