Hi,
I got sheets which calculate numbers for a certain input (yellow field) on the sheet.
sheet "disitri1":
To make a summary I need to input these values into the sheet and then copy a value of a resulting cell (F52) to the summary.
(Reason: each distri1, distri2, etc includes very individual data so is very hard to combine in one sheet, and number of distri will increase)
summary sheet:
This should be done on a certain range, even though there might exist no values.
I get an infinite loop. Does "For Each" not work? The line where the debugger stops is
"Sheets(distributor).Select"
I just get into VBA again, maybe you can shortly comment on my code.
Thank you.
mos
P.S. I use Windows XP and Excel
PPS I could not declare Dim xCell A Cell, any idea why?
I got sheets which calculate numbers for a certain input (yellow field) on the sheet.
sheet "disitri1":
To make a summary I need to input these values into the sheet and then copy a value of a resulting cell (F52) to the summary.
(Reason: each distri1, distri2, etc includes very individual data so is very hard to combine in one sheet, and number of distri will increase)
summary sheet:
This should be done on a certain range, even though there might exist no values.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xarea As Range
Dim xCol As Long
Dim xRow As Long
Dim xcell As Object
Dim distributor As String
Dim quarter As String
Dim valuetocopy As Integer
Dim usedsheet As String
usedsheet = ActiveSheet.Name
Set xarea = Sheets(usedsheet).Range("F6:H17")
For Each xcell In xarea.Cells
xCol = xcell.Column
xRow = xcell.Row
distributor = Cells(3, xCol).Value
quarter = Cells(xRow, 1).Value
Sheets(distributor).Select
Range("C15:D15").Value = quarter
valuetocopy = Range("F52").Value
Sheets(usedsheet).Select
xcell.Value = valuetocopy
Next
End Sub
I get an infinite loop. Does "For Each" not work? The line where the debugger stops is
"Sheets(distributor).Select"
I just get into VBA again, maybe you can shortly comment on my code.
Thank you.
mos
P.S. I use Windows XP and Excel
PPS I could not declare Dim xCell A Cell, any idea why?