Copying value to another worksheet

Closed
NewToMacro - Feb 22, 2012 at 08:57 PM
 Blocked Profile - Feb 22, 2012 at 11:31 PM
Hello,

I am trying to copy a value for from one worksheet, do some math --> say I have three values that I want to subtract separately from cell i,j then find out which is the minimum...but I am having problems! And I am wondering if you guys can help me out.

Here's my code so far:

Sub Macro1()
'
' Macro1 Macro
'

'
Dim i As Integer
Dim urban As Integer
Dim vegetation As Integer
Dim water As Integer
Dim min As Integer
Dim class As String
Dim urban_ave As Integer, vege_ave As Integer, wat_ave As Integer
Dim insheet As Worksheet, out As Worksheet, average As Worksheet

urban_ave = 127
vege_ave = 75
wat_ave = 48

For i = 266 To 267
For j = 1 To 3
water = (insheet.Cells(i, j).value - (wat_ave)
urban = (insheet.Cells(i, j).Value) - (urban_ave)
vegetation = (insheet.Cells(i, j).Value) - (vege_ave)
If water > urban Then
min = urban & out.Cells(i, j).Value = "U"
Else
min = water & out.Cells(i, j).Value = "W"
End If

If min > vegetation Then
min_final = vegetation
Else
min_final = min & out.Cells(i, j).Value = "V"
End If

Next j
Next i

End Sub

1 response

Blocked Profile
Feb 22, 2012 at 11:31 PM
Greetings,

Please, bare in mind that Kioskea is a mutual aid community, all answers on the forum are provided by volunteers who give their time free to help solve issues.

Therefore, it is specifically requested from Kioskea forum users correspond showing mutual respect. Therefore, when requesting assistance, the use of polite expressions,as for elsewhere in similar circumstances, is appreciated. (please, thank you, appreciate, grateful, etc.)

https://ccm.net/apps-sites/internet-archeology/ccm/10131-terms-of-use-for-ccm-respect-for-others/#politesse

Please, copy, modify and repost your message respecting the politeness charter.

We trust that you understand.

Moderator
0