K
kamakshi
I have code here. it is updating the summary . but it is not totalling
properly. please correct ti and resend it to me my email address is
(e-mail address removed)
Sub Get_Totals()
Application.ScreenUpdating = False
Dim mystrdate
Dim mystrname
Dim mylen As Integer
Dim sumlastrow As Long
Dim invlastrow As Long
Dim thiscol As Integer
Dim lastrow As Integer
Dim f As Integer
invlastrow = Sheets("Inventory
Template").Range("C65336").End(xlUp).Row
Sheets("Summary").Range("B5:C2000").ClearContents
For f = 7 To invlastrow
mystrname = Trim(Cells(f, 3).Text) '' This set the name
mystrdate = Right(Cells(f, 14), 4) ''this is for the date
If mystrdate < 1990 Then ''' now check each cell for years less
than 1990
Range(Cells(f, 1), Cells(f, 50)).Interior.ColorIndex = "6" ''
color to yellow if < 1990
ElseIf mystrdate > 1990 And mystrdate <> "" Then
Range(Cells(f, 1), Cells(f, 50)).Interior.ColorIndex = "8" ''
color to blue if > 1990
ElseIf Cells(f, 4).Text = "Master" Then
Range(Cells(f, 1), Cells(f, 50)).Interior.ColorIndex = "8"
End If
Sheets("Summary").Activate
sumlastrow = Sheets("Summary").Range("A65336").End(xlUp).Row + 1
''get lastrow on summry
On Error Resume Next
Sheets("Summary").Cells.Find(What:=mystrname,
LookAt:=xlWhole).Select
If Sheets("Summary").Cells(ActiveCell.Row, 2).Value = "" Then
Sheets("Summary").Cells(ActiveCell.Row, 2).Value = 0
Sheets("Summary").Cells(ActiveCell.Row, 3).Value = 0
End If
If Err = "91" Then
Sheets("Summary").Cells(sumlastrow, 1).Value = mystrname
Sheets("Summary").Cells(sumlastrow, 1).Select
Sheets("Summary").Cells(sumlastrow, 2).Value = 0
Sheets("Summary").Cells(sumlastrow, 3).Value = 0
End If
If mystrdate < 1990 Then ''' now check each cell for years less
than 1990
ActiveCell.Offset(, 2).Value = ActiveCell.Offset(, 2).Text
+ 1 ''add to total
Else
ActiveCell.Offset(, 1).Value = ActiveCell.Offset(, 1).Text
+ 1 '''add to total
End If
Sheets("Inventory Template").Activate
Next f
End Sub
properly. please correct ti and resend it to me my email address is
(e-mail address removed)
Sub Get_Totals()
Application.ScreenUpdating = False
Dim mystrdate
Dim mystrname
Dim mylen As Integer
Dim sumlastrow As Long
Dim invlastrow As Long
Dim thiscol As Integer
Dim lastrow As Integer
Dim f As Integer
invlastrow = Sheets("Inventory
Template").Range("C65336").End(xlUp).Row
Sheets("Summary").Range("B5:C2000").ClearContents
For f = 7 To invlastrow
mystrname = Trim(Cells(f, 3).Text) '' This set the name
mystrdate = Right(Cells(f, 14), 4) ''this is for the date
If mystrdate < 1990 Then ''' now check each cell for years less
than 1990
Range(Cells(f, 1), Cells(f, 50)).Interior.ColorIndex = "6" ''
color to yellow if < 1990
ElseIf mystrdate > 1990 And mystrdate <> "" Then
Range(Cells(f, 1), Cells(f, 50)).Interior.ColorIndex = "8" ''
color to blue if > 1990
ElseIf Cells(f, 4).Text = "Master" Then
Range(Cells(f, 1), Cells(f, 50)).Interior.ColorIndex = "8"
End If
Sheets("Summary").Activate
sumlastrow = Sheets("Summary").Range("A65336").End(xlUp).Row + 1
''get lastrow on summry
On Error Resume Next
Sheets("Summary").Cells.Find(What:=mystrname,
LookAt:=xlWhole).Select
If Sheets("Summary").Cells(ActiveCell.Row, 2).Value = "" Then
Sheets("Summary").Cells(ActiveCell.Row, 2).Value = 0
Sheets("Summary").Cells(ActiveCell.Row, 3).Value = 0
End If
If Err = "91" Then
Sheets("Summary").Cells(sumlastrow, 1).Value = mystrname
Sheets("Summary").Cells(sumlastrow, 1).Select
Sheets("Summary").Cells(sumlastrow, 2).Value = 0
Sheets("Summary").Cells(sumlastrow, 3).Value = 0
End If
If mystrdate < 1990 Then ''' now check each cell for years less
than 1990
ActiveCell.Offset(, 2).Value = ActiveCell.Offset(, 2).Text
+ 1 ''add to total
Else
ActiveCell.Offset(, 1).Value = ActiveCell.Offset(, 1).Text
+ 1 '''add to total
End If
Sheets("Inventory Template").Activate
Next f
End Sub