Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Macro Problem

Status
Not open for further replies.

useractive

Programmer
Jun 21, 2001
98
US
Ok, I have the following Script that looks over does a bunch of stuff and then takes out all the V's when doing it's calculation (voids). Now they tell me the script also needs to remove the any R statuses as well. Since I'm not good at programming and Ken helped me with this one (Still owe ya one) I need help throwing in the R removal.

Sub fill()
Worksheets("Cleanup").Activate
Range("A3").Select
Worksheets("Dirty").Activate
Dim i As Integer
Dim fromwks As String
fromwks = Worksheets("Dirty").Name
Dim fromcell As String
Dim r As Range
Set r = Intersect(ActiveSheet.UsedRange, Range("G2:G65536"))
For i = 1 To r.Count
If r.Cells(i).Value = 1 Then
If r.Cells(i).Offset(0, 1).Value = "V" Then
Else
r.Cells(i).Select
fromcell = ActiveCell.Address(False, False)
Worksheets("Cleanup").Activate
ActiveCell.Formula = _
"=" & fromwks & "!" & fromcell
ActiveCell.Offset(0, 1).Select
Worksheets("Dirty").Select
r.Cells(i).Offset(0, -6).Select
fromcell = ActiveCell.Address(False, False)
Worksheets("Cleanup").Activate
ActiveCell.Formula = _
"=" & fromwks & "!" & fromcell
ActiveCell.Offset(0, 2).Select
Worksheets("Dirty").Activate
r.Cells(i).Offset(0, -1).Select
fromcell = ActiveCell.Address(False, False)
Worksheets("Cleanup").Activate
ActiveCell.Formula = _
"=" & fromwks & "!" & fromcell
ActiveCell.Offset(0, 4).Select
Worksheets("Dirty").Activate
r.Cells(i).Offset(0, -3).Select
fromcell = ActiveCell.Address(False, False)
Worksheets("Cleanup").Activate
ActiveCell.Formula = _
"=" & fromwks & "!" & fromcell
ActiveCell.Offset(1, -7).Select
Worksheets("Dirty").Activate
End If
Else
Range("B200", "C200").Select
Selection.Copy
Worksheets("Cleanup").Activate
ActiveSheet.Paste
Worksheets("Dirty").Activate
Application.CutCopyMode = False
Exit For
End If
Next i
Worksheets("Cleanup").Activate
Range("C1").Select
Selection.EntireColumn.Select
Selection.ColumnWidth = 1.67
Range("A3").Select
startcell = ActiveCell.Address(False, False)
ActiveCell.End(xlDown).Select
endcell = ActiveCell.Address(False, False)
ActiveCell.Offset(1, 0).Select
ActiveCell.Formula = _
"=SUM(" & startcell & ":" & endcell & ")"
ActiveCell.NumberFormat = "0000000000"
ActiveCell.Offset(-1, 1).Select
Dim tmp As String
tmp = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
ActiveCell.Formula = _
tmp & "T"
ActiveCell.HorizontalAlignment = xlLeft
ActiveCell.Offset(0, -1).Select
tmp = ActiveCell.Address(False, False)
Dim tmp5 As String
ActiveCell.Offset(0, 7).Select
tmp5 = ActiveCell.Address(False, False)
ActiveCell.Offset(0, -4).Select
Dim tmp2 As String
Dim tmp3 As String
Dim tmp4 As String
tmp2 = """"
tmp3 = Mid(tmp2, 2, 1)
tmp4 = "0000000000"
ActiveCell.Formula = _
"=TEXT(" & tmp & ", " & """0000000000""" & ")&TEXT(" & tmp5 & "*100, " & """000000000000""" & ")"
ActiveCell.Offset(-1, 4).Select
endcell = ActiveCell.Address
ActiveCell.End(xlUp).Select
startcell = ActiveCell.Address
ActiveCell.End(xlDown).Select
Selection.Offset(1, 0).Select
ActiveCell.Formula = _
"=SUM(" & startcell & ":" & endcell & ")"
ActiveCell.NumberFormat = "#,###.##"
Sheets("Cleanup").Select
ActiveWindow.ScrollRow = 1
Range("F1:F200").Select
Selection.Copy
Sheets("Information").Select
Dim RetVal
RetVal = Shell("C:\Windows\NOTEPAD.EXE", 1)
End Sub
 
From what I can see, you should be able to change this line:
If r.Cells(i).Offset(0, 1).Value = "V" Then
to
If r.Cells(i).Offset(0, 1).Value = "V" or r.cells(i).offset(0, 1).Value = "R" Then


Rgds
Geoff
Si hoc legere scis, nimis eruditionis habes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top