sub total

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
 
R

R. Choate

By the way, it is also poor etiquette to ask people to send responses directly to you. Everything is generally supposed to remain in
the forum unless a helper specifically offers to work with you directly. Remember, the forums are for the benefit of all. They are
not for the personal education of individuals who happen to need help. In addition to that, you are very likely to start getting
spammed because you are putting your real email address in your posts. Spammers love to lift email addresses from these NGs. You
need to read this ---> http://www.mvps.org/access/netiquette.htm

--
RMC,CPA



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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top