Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Down one cell at a time

Hi im having problems programming a small function that
will go down one cell at a time comparing the cell to
previous one. My problems stems from trying to get the
range to move one cell down. I tried using
SendKeys "{DOWN}" but it cuases the application to just
hang. Changign the range select by interval of 1 won't cut
it becuase I use this in spreedsheets where I often filter
many rows so row 1 can be next to row 2000, looking for
row 2 column A won't help me. Does anyone know why
SendKeys "{DOWN}" won't work? Or is there a better way to
get the program to move down one cell at a time? Note I
tried usign Enter key instead of Down Arrow aswell, that
didnt help either.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Down one cell at a time

WCyrek,

Activecell.Offset(1,0).Select

John

"WCyrek" wrote in message
...
Hi im having problems programming a small function that
will go down one cell at a time comparing the cell to
previous one. My problems stems from trying to get the
range to move one cell down. I tried using
SendKeys "{DOWN}" but it cuases the application to just
hang. Changign the range select by interval of 1 won't cut
it becuase I use this in spreedsheets where I often filter
many rows so row 1 can be next to row 2000, looking for
row 2 column A won't help me. Does anyone know why
SendKeys "{DOWN}" won't work? Or is there a better way to
get the program to move down one cell at a time? Note I
tried usign Enter key instead of Down Arrow aswell, that
didnt help either.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 194
Default Down one cell at a time

Tom Ogilvy gave me this code to increment down one cell at a time in a
single column on a filtered sheet. I have this as a separate macro and
insert a call to it when I need to go down a cell. It works great for me.

Ed

Sub Increment1()
Dim rng As Range, rng1 As Range
Dim icol As Long
icol = ActiveCell.Column
Set rng = ActiveSheet.AutoFilter.Range
Set rng = Intersect(rng, Columns(icol))
Set rng = Range(ActiveCell.Offset(1, 0), rng(rng.Count))
On Error Resume Next
Set rng1 = rng.SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1(1).Select
End If
End Sub

"WCyrek" wrote in message
...
Hi im having problems programming a small function that
will go down one cell at a time comparing the cell to
previous one. My problems stems from trying to get the
range to move one cell down. I tried using
SendKeys "{DOWN}" but it cuases the application to just
hang. Changign the range select by interval of 1 won't cut
it becuase I use this in spreedsheets where I often filter
many rows so row 1 can be next to row 2000, looking for
row 2 column A won't help me. Does anyone know why
SendKeys "{DOWN}" won't work? Or is there a better way to
get the program to move down one cell at a time? Note I
tried usign Enter key instead of Down Arrow aswell, that
didnt help either.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Down one cell at a time

Thank you both! I will be sure to try both of your
solutions ASAP!

-----Original Message-----
Tom Ogilvy gave me this code to increment down one cell

at a time in a
single column on a filtered sheet. I have this as a

separate macro and
insert a call to it when I need to go down a cell. It

works great for me.

Ed

Sub Increment1()
Dim rng As Range, rng1 As Range
Dim icol As Long
icol = ActiveCell.Column
Set rng = ActiveSheet.AutoFilter.Range
Set rng = Intersect(rng, Columns(icol))
Set rng = Range(ActiveCell.Offset(1, 0), rng(rng.Count))
On Error Resume Next
Set rng1 = rng.SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1(1).Select
End If
End Sub

"WCyrek" wrote in

message
...
Hi im having problems programming a small function that
will go down one cell at a time comparing the cell to
previous one. My problems stems from trying to get the
range to move one cell down. I tried using
SendKeys "{DOWN}" but it cuases the application to just
hang. Changign the range select by interval of 1 won't

cut
it becuase I use this in spreedsheets where I often

filter
many rows so row 1 can be next to row 2000, looking for
row 2 column A won't help me. Does anyone know why
SendKeys "{DOWN}" won't work? Or is there a better way

to
get the program to move down one cell at a time? Note I
tried usign Enter key instead of Down Arrow aswell, that
didnt help either.



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Down one cell at a time

Ed,

I tried your way, seems closer to perfect. However I find
it that once it gets to the end of the filtered rows where
I have Loop Until (ActiveCell.FormulaR1C1 = "") the
ptogram just hangs and I must use ctrl break to exit. And
the debuger always points to End If in Incriment1 or On
Error GoTo 0.

Here is what im working with for reference

Public MyStr As String
Public CounterN As Integer

Private Sub CaseCommandButton_Click()
Counter.Hide
Range("A1").Select
Call Increment1
MyStr = "Start"
CounterN = 0
Do
Call CountUP
Loop Until (ActiveCell.FormulaR1C1 = "")
MsgBox ("The final number is " & CounterN)
Unload Counter
End Sub

Private Function CountUP()
If ActiveCell.FormulaR1C1 = MyStr Then
MyStr = ActiveCell.FormulaR1C1
Else
MyStr = ActiveCell.FormulaR1C1
CounterN = CounterN + 1
End If
Call Increment1
End Function


-----Original Message-----
Tom Ogilvy gave me this code to increment down one cell

at a time in a
single column on a filtered sheet. I have this as a

separate macro and
insert a call to it when I need to go down a cell. It

works great for me.

Ed

Sub Increment1()
Dim rng As Range, rng1 As Range
Dim icol As Long
icol = ActiveCell.Column
Set rng = ActiveSheet.AutoFilter.Range
Set rng = Intersect(rng, Columns(icol))
Set rng = Range(ActiveCell.Offset(1, 0), rng(rng.Count))
On Error Resume Next
Set rng1 = rng.SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1(1).Select
End If
End Sub

"WCyrek" wrote in

message
...
Hi im having problems programming a small function that
will go down one cell at a time comparing the cell to
previous one. My problems stems from trying to get the
range to move one cell down. I tried using
SendKeys "{DOWN}" but it cuases the application to just
hang. Changign the range select by interval of 1 won't

cut
it becuase I use this in spreedsheets where I often

filter
many rows so row 1 can be next to row 2000, looking for
row 2 column A won't help me. Does anyone know why
SendKeys "{DOWN}" won't work? Or is there a better way

to
get the program to move down one cell at a time? Note I
tried usign Enter key instead of Down Arrow aswell, that
didnt help either.



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Down one cell at a time

Private Sub CaseCommandButton_Click()
Counter.Hide
MyStr = "Start"
CounterN = Application.countif(Range("A:A"),MyStr)
MsgBox ("The final number is " & CounterN)
Unload Counter
End Sub

--
Regards,
Tom Ogilvy


wrote in message
...
Ed,

I tried your way, seems closer to perfect. However I find
it that once it gets to the end of the filtered rows where
I have Loop Until (ActiveCell.FormulaR1C1 = "") the
ptogram just hangs and I must use ctrl break to exit. And
the debuger always points to End If in Incriment1 or On
Error GoTo 0.

Here is what im working with for reference

Public MyStr As String
Public CounterN As Integer

Private Sub CaseCommandButton_Click()
Counter.Hide
Range("A1").Select
Call Increment1
MyStr = "Start"
CounterN = 0
Do
Call CountUP
Loop Until (ActiveCell.FormulaR1C1 = "")
MsgBox ("The final number is " & CounterN)
Unload Counter
End Sub

Private Function CountUP()
If ActiveCell.FormulaR1C1 = MyStr Then
MyStr = ActiveCell.FormulaR1C1
Else
MyStr = ActiveCell.FormulaR1C1
CounterN = CounterN + 1
End If
Call Increment1
End Function


-----Original Message-----
Tom Ogilvy gave me this code to increment down one cell

at a time in a
single column on a filtered sheet. I have this as a

separate macro and
insert a call to it when I need to go down a cell. It

works great for me.

Ed

Sub Increment1()
Dim rng As Range, rng1 As Range
Dim icol As Long
icol = ActiveCell.Column
Set rng = ActiveSheet.AutoFilter.Range
Set rng = Intersect(rng, Columns(icol))
Set rng = Range(ActiveCell.Offset(1, 0), rng(rng.Count))
On Error Resume Next
Set rng1 = rng.SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1(1).Select
End If
End Sub

"WCyrek" wrote in

message
...
Hi im having problems programming a small function that
will go down one cell at a time comparing the cell to
previous one. My problems stems from trying to get the
range to move one cell down. I tried using
SendKeys "{DOWN}" but it cuases the application to just
hang. Changign the range select by interval of 1 won't

cut
it becuase I use this in spreedsheets where I often

filter
many rows so row 1 can be next to row 2000, looking for
row 2 column A won't help me. Does anyone know why
SendKeys "{DOWN}" won't work? Or is there a better way

to
get the program to move down one cell at a time? Note I
tried usign Enter key instead of Down Arrow aswell, that
didnt help either.



.



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
If statement to compare time cell to a time Z-Man-Cek Excel Worksheet Functions 16 July 29th 16 08:17 AM
Take a 3 or for digit time and convet it to time in one cell Djbaker70 Excel Worksheet Functions 9 August 16th 08 11:55 AM
Extracting Time from a cell that has both the date and the time Hani Muhtadi Excel Discussion (Misc queries) 3 September 9th 05 10:59 AM
Adding time to date-time formatted cell tawtrey(remove this )@pacificfoods.com Excel Discussion (Misc queries) 4 August 12th 05 10:53 PM
how do i type a time into a cell formatted for time? Armadillo Excel Discussion (Misc queries) 4 June 16th 05 11:32 PM


All times are GMT +1. The time now is 12:27 AM.

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

About Us

"It's about Microsoft Excel"