Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
If statement to compare time cell to a time | Excel Worksheet Functions | |||
Take a 3 or for digit time and convet it to time in one cell | Excel Worksheet Functions | |||
Extracting Time from a cell that has both the date and the time | Excel Discussion (Misc queries) | |||
Adding time to date-time formatted cell | Excel Discussion (Misc queries) | |||
how do i type a time into a cell formatted for time? | Excel Discussion (Misc queries) |