Copying value to another worksheet [Closed]

Report
-
 Blocked Profile -
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 reply


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/contents/948-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

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!