G
Guest
The following code steps through all the worksheets and all the cells in the
range f2 thru f40, If the value in Fx = projectname I want to add the values
in the cell to the left, Ex. Using the for each statement is nice but how do
I get the info from Ex if Fx = projectname. I have tried to make E a variable
based on Cel, a collection object, but I keep getting errrors.
This is the line that is crashing:
TotalHoursToDate.Text = CDbl(TotalHoursToDate.Text) + CDbl(Range("cel.Column
- 1" & "cel.Row")) ' does not work - ie. F20 & E20
It would look like this:
if projectname = bell then
Total = Total + E20
end if
This is the part of that line that I need to work but doesn't:
CDbl(Range("cel.Column - 1" & "cel.Row")) ' ie. F20 & E20
'MsgBox (1)
Dim sht As Worksheet
Dim cel As Range
Dim j, column As Integer
For Each sht In Worksheets
For Each cel In sht.Range("F2:F40")
column = E
MsgBox (Cells("column & cel.Row"))
If cel.Text = TotalHours.Projects.Text Then
TotalHoursToDate.Text = CDbl(TotalHoursToDate.Text) +
CDbl(Range("cel.Column - 1" & "cel.Row")) ' does not work
'TotalHoursToDate.Text = CDbl(TotalHoursToDate.Text) +
CDbl(TotalHoursToDate.Text) ' works
End If
'MsgBox (cel.Row)
Next cel
Next sht
Thank you for the help. I have searched thru meny articles but I cant apply
their suggestion of the for each in this case!
range f2 thru f40, If the value in Fx = projectname I want to add the values
in the cell to the left, Ex. Using the for each statement is nice but how do
I get the info from Ex if Fx = projectname. I have tried to make E a variable
based on Cel, a collection object, but I keep getting errrors.
This is the line that is crashing:
TotalHoursToDate.Text = CDbl(TotalHoursToDate.Text) + CDbl(Range("cel.Column
- 1" & "cel.Row")) ' does not work - ie. F20 & E20
It would look like this:
if projectname = bell then
Total = Total + E20
end if
This is the part of that line that I need to work but doesn't:
CDbl(Range("cel.Column - 1" & "cel.Row")) ' ie. F20 & E20
'MsgBox (1)
Dim sht As Worksheet
Dim cel As Range
Dim j, column As Integer
For Each sht In Worksheets
For Each cel In sht.Range("F2:F40")
column = E
MsgBox (Cells("column & cel.Row"))
If cel.Text = TotalHours.Projects.Text Then
TotalHoursToDate.Text = CDbl(TotalHoursToDate.Text) +
CDbl(Range("cel.Column - 1" & "cel.Row")) ' does not work
'TotalHoursToDate.Text = CDbl(TotalHoursToDate.Text) +
CDbl(TotalHoursToDate.Text) ' works
End If
'MsgBox (cel.Row)
Next cel
Next sht
Thank you for the help. I have searched thru meny articles but I cant apply
their suggestion of the for each in this case!