sduray
10-31-2008, 06:49 AM
Hello,
I have another problem with the VBA code. This one was writtend by someone more knowledgeable than I. Unfortunately, I have been unable to utilize it. This code was written to allow me to sort my active worksheet by using a set of values. Basically, in the report I receive, in column O there are different values, and I am just trying to extract a subset of values that I need from it (I just want to hide the other values rather than deleting them if possible). This subset of values comes from a separate spreadsheet.
To summarize, in the active spreadsheet that I am working on formatting has 13 columns (active columns are a, b, c, d, e, f, o, p, r, x, ab, ax, ay). The reference spreadsheet has only one columnl--a.
However, when I run the following code I get a debug error that I don't know how to fix :help :
Sub Name()
Dim x As Integer
Dim i As Integer
Dim y As Integer
Dim b As Integer
Dim z As String
Worksheets("Sheet 2").Select
Range("a2").Select
x = Range("A2", Range("a2").End(xlDown)).Cells.Count
Dim codes(10)
For i = 1 To x
codes(i) = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
MsgBox codes(i)
Next i
Worksheets("Sheet1").Select
Range("a2").Select
Do Until IsEmpty(ActiveCell)
For b = 1 To x
z = codes(b)
If ActiveCell.Value = codes(b) Then
y = y + 1
End If
Next b
Debug.Print y
If y = 0 Then
ActiveCell.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If
y = 0
Loop
End Sub
Thank you for your help,
SD
I have another problem with the VBA code. This one was writtend by someone more knowledgeable than I. Unfortunately, I have been unable to utilize it. This code was written to allow me to sort my active worksheet by using a set of values. Basically, in the report I receive, in column O there are different values, and I am just trying to extract a subset of values that I need from it (I just want to hide the other values rather than deleting them if possible). This subset of values comes from a separate spreadsheet.
To summarize, in the active spreadsheet that I am working on formatting has 13 columns (active columns are a, b, c, d, e, f, o, p, r, x, ab, ax, ay). The reference spreadsheet has only one columnl--a.
However, when I run the following code I get a debug error that I don't know how to fix :help :
Sub Name()
Dim x As Integer
Dim i As Integer
Dim y As Integer
Dim b As Integer
Dim z As String
Worksheets("Sheet 2").Select
Range("a2").Select
x = Range("A2", Range("a2").End(xlDown)).Cells.Count
Dim codes(10)
For i = 1 To x
codes(i) = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
MsgBox codes(i)
Next i
Worksheets("Sheet1").Select
Range("a2").Select
Do Until IsEmpty(ActiveCell)
For b = 1 To x
z = codes(b)
If ActiveCell.Value = codes(b) Then
y = y + 1
End If
Next b
Debug.Print y
If y = 0 Then
ActiveCell.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If
y = 0
Loop
End Sub
Thank you for your help,
SD