View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Damon Longworth Damon Longworth is offline
external usenet poster
 
Posts: 111
Default row location....hopefully simple answer :-)

To get the last used row, try something similar to:

MyLastRow = Range("A65536").end(xlup).row

Same logic to get columns:

MyLastCol = Range("IV4").End(xlToLeft).column

You do not have to activate while filling your array:

For q = 1 To colct
tval(q) = Worksheets("Sheet1").Range("A5").offset(0,q).Value
next

These suggestions will avoid the need to return to your original location
and speed up your code.


--
Damon Longworth

Don't miss out on the 2005 Excel User Conference
Sept 16th and 17th
Stockyards Hotel - Ft. Worth, Texas
www.ExcelUserConference.com


"cadcamguy" wrote in message
...
okay don't laugh too hard :-)

I have unknown cols and rows coming in so I those supscripted avlues I can
bump up

another program ..ProE lauches excel... so I do get some formatting done
for
me
It's a lot easier to add more parts... the rows in excel than ProE
Just checking to see if you have the same values.... the exact same size
part is a pain in ProE
it's manual... so hacked this out ...I did it on the fly the function is
just a repeat of commandbutton 2
I couldn't get it to fire the button in the auto mode...it's a pasta dish
:-)
started out driving it and looking to put on autopilot.... it's great that
there is this assistance here
but oldtimer that I am ... I know I'll learn better by mistake :-)


Dim rowct As String: Dim colct As Integer
Dim cval(6) As String: Dim tval(6) As String
Dim ck(6) As Integer: Dim ckval As Integer
Dim wrfile As String

Private Sub CommandButton5_Click()
Do While ActiveCell.Value < ""
auto_ck
Loop
Rows(rowct).Activate

End Sub

Private Sub UserForm_Activate()
Worksheets("Sheet1").Activate
Worksheets("Sheet1").Range("A4").Activate ' startpont

Do Until ActiveCell.Value = "" 'count up columns
colct = colct + 1
ActiveCell.Offset(0, 1).Activate
Loop

Worksheets("Sheet1").Range("A5").Activate ' to generic row home
'TextBox2.Text = ActiveCell.Value
End Sub
Private Sub CommandButton1_Click() 'read
TextBox2.Text = ActiveCell.Value ' compare against
For q = 1 To colct
ActiveCell.Offset(0, 1).Activate
cval(q) = ActiveCell.Value ' read in col values
Next q

ActiveCell.Offset(0, -(colct)).Activate 'back to first col
ActiveCell.Offset(1, 0).Activate 'down a row for safety
CommandButton2.Visible = True
TextBox1.Text = ActiveCell.Value ' current instance name

'rowct = ActiveCell
rowct = ActiveCell.Row
TextBox1.Text = rowct

End Sub
Private Sub CommandButton2_Click() 'ck&del
For q = 1 To colct
ActiveCell.Offset(0, 1).Activate
tval(q) = ActiveCell.Value
If tval(q) = cval(q) Then ' see if values the same
ck(q) = 1 'same value
Else
ck(q) = 0 ' not the same
End If
Next q

ActiveCell.Offset(0, -(colct)).Activate 'return to start col

For q = 1 To colct ' add up check values
ckval = ckval + ck(q)
Next q

If ckval = colct Then ' delete if all ones pass if not
Worksheets("Sheet1").Rows(ActiveCell.Row).Delete
Else
ActiveCell.Offset(1, 0).Activate ' move down a row
End If
ckval = 0
TextBox1.Text = ActiveCell.Value
End Sub
Private Sub CommandButton3_Click() 'down
ActiveCell.Offset(1, 0).Activate
TextBox1.Text = ActiveCell.Value 'curr inst
End Sub
Private Sub CommandButton4_Click() 'up
ActiveCell.Offset(-1, 0).Activate
TextBox1.Text = ActiveCell.Value 'curr inst
End Sub


Public Function auto_ck()
For q = 1 To colct
ActiveCell.Offset(0, 1).Activate
tval(q) = ActiveCell.Value
If tval(q) = cval(q) Then ' see if values the same
ck(q) = 1 'same value
Else
ck(q) = 0 ' not the same
End If
Next q

ActiveCell.Offset(0, -(colct)).Activate 'return to start col

For q = 1 To colct ' add up check values
ckval = ckval + ck(q)
Next q

If ckval = colct Then ' delete if all ones pass if not
Worksheets("Sheet1").Rows(ActiveCell.Row).Delete
Else
ActiveCell.Offset(1, 0).Activate ' move down a row
End If
ckval = 0
TextBox1.Text = ActiveCell.Value
End Function