Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default row location....hopefully simple answer :-)

I get my start row .... rowct=activecell.row
then I use a do until loop that goes down and then stops on a
cellactive.value
then I want to go back to the row based on my rowct value
I'm on the right column

is there a command that I can use to move back to rowct

I'm sure it's something simple, I don't seem to be able to find it... newbie
and all


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default row location....hopefully simple answer :-)

I don't know why you have to leave it in the first place because you rarely
need to select cells to act on them. Post your code for comments or

rows(rowct).select

--
Don Guillett
SalesAid Software

"cadcamguy" wrote in message
...
I get my start row .... rowct=activecell.row
then I use a do until loop that goes down and then stops on a
cellactive.value
then I want to go back to the row based on my rowct value
I'm on the right column

is there a command that I can use to move back to rowct

I'm sure it's something simple, I don't seem to be able to find it...

newbie
and all




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default row location....hopefully simple answer :-)

Well I am by no means versed in excel... I am most likely doing this alll
wrong... I'm taking a VB approach

but the rows(rowct).select
is getting me back, but I don't need to select the whole row
but it's not making any difference to what I am doing


which is just checking the values of all cols ....looping thru the rows to
see if there are any indentical entrys
it's not a large sheet ...It's all a learning experience....:-)

While I like what I am seeing what you can do with excel and vba... my brain
is overloading
between vb,vbs,vba and then cad/cam .. there isn't much more room in my head
for syntax

I can post the code if you need a good laugh :-)..it's been a okay add a
button to do this
hey that works...okay add this and so on..... I am machinist and a real hack
when it comes to
this stuff

Thanks...my wife is real good at this ... but she will not answer my
questions :-)


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default row location....hopefully simple answer :-)

Hi CadCamGuy,

First answer:

Set rowct = ActiveCell
'your code
rowct.Select

Second answer:

It is rarely necessary, or desirable to make selections. Doing so often
results in slower, less efficient code.

Here is a simple example of looping code which checks for a test value
without making selections:

Sub Tester()
Dim Rng As Range
Dim rCell As Range
Dim sStr As String

sStr = "Tom" <<=== Your test value

Set Rng = Range("A1:A20")

For Each rCell In Rng.Cells
If rCell.Value < sStr Then
'do something, e.g.:
MsgBox rCell.Value
Else
MsgBox "Found """ & sStr & """ in cell " _
& rCell.Address
Exit For
End If
Next rCell
End Sub

---
Regards,
Norman



"cadcamguy" wrote in message
...
I get my start row .... rowct=activecell.row
then I use a do until loop that goes down and then stops on a
cellactive.value
then I want to go back to the row based on my rowct value
I'm on the right column

is there a command that I can use to move back to rowct

I'm sure it's something simple, I don't seem to be able to find it...
newbie
and all




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default row location....hopefully simple answer :-)

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




  #6   Report Post  
Posted to microsoft.public.excel.programming
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




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default row location....hopefully simple answer :-)

So I don't have to drive the activecell around the sheet, I can stay parked
to get the values..I like that.
I moved the activecell around so that I could get an idea when I was.... I
just started adding more buttons
once I saw that I was getting what I needed

This looks like I check from the outside to find what is used inside

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


And the offset function.. I really don't have to make active also..less
driving there too

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

Hey this is making more sense, I do have some books with a little info on
excel...most of it deals with VB6

Hey thanks... this is cool stuff


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a simple answer? Jim May Excel Discussion (Misc queries) 2 December 20th 07 07:14 PM
Simple Question, But No Answer Joe Teixeira Excel Worksheet Functions 2 December 19th 06 12:16 AM
There may be a simple answer ... Lee Bowman Excel Discussion (Misc queries) 2 November 8th 05 03:41 PM
So simple I can't find the answer! Mark \(InWales\)[_3_] Excel Programming 3 October 15th 04 07:03 AM
simple question, hopefully a simple answer! Matt B Excel Programming 5 January 13th 04 08:43 PM


All times are GMT +1. The time now is 11:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"