LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
DMB
 
Posts: n/a
Default How do I add the E column basd on the F column

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!
 
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
Check COlumn - Excel VBA magix Excel Discussion (Misc queries) 11 November 5th 05 02:32 AM
creating a bar graph Johnfli Excel Discussion (Misc queries) 0 October 26th 05 08:16 PM
Count Position of Filtered TEXT cells in a column Sam via OfficeKB.com Excel Worksheet Functions 8 May 18th 05 04:23 AM
How to group similar column titles together???? vrk1 Excel Discussion (Misc queries) 2 April 30th 05 12:17 AM
Return Count for LAST NonBlank Cell in each Row Sam via OfficeKB.com Excel Worksheet Functions 12 April 17th 05 10:36 PM


All times are GMT +1. The time now is 03:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"