Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default needs to run faster

Ok, here is the code I currently have. I got some from on here, and
some,(the really slow part) is my first attempt at VBA. The changes I
need to make are as follows. The workbook contains sheets called 1, 2,
3, 4, 5, etc, all the way to 31. (seperate sheet for each day of the
month). I need this formula to work on the active sheet, no matter
which sheet it is on. The second problem is the speed of the DO UNTIL
loop. The 400 is there because I know that none of teh data that is
copied into the A column goes beyond 400 rows. Any help would eb
greatly appreciated

Sub test()
Call RemoveDuplicates("=")
Call tr
End Sub


Public Sub RemoveDuplicates(ByVal ReplaceCharacter As String)
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range


Set wks = Sheets("1")
Set rngToSearch = wks.Range("a:a")
Set rngFound = rngToSearch.Find(What:=ReplaceCharacter & _
ReplaceCharacter, LookAt:=xlPart)


Do While Not rngFound Is Nothing
rngToSearch.Replace What:=ReplaceCharacter, _
Replacement:=""
Set rngFound = rngToSearch.Find(What:=ReplaceCharacter & _
ReplaceCharacter, LookAt:=xlPart)
Loop
End Sub
Sub tr()
Dim i As Integer
i = 0
Do Until i = 400
i = i + 1
If Cells(i, 1) = "" Then Cells(i, 1).Delete
Cells(i, 2).Value = Application.Trim(Cells(i, 1))
Loop


End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default needs to run faster

Not sure exactly what TR is supposed to do but try this without the
loop. This deletes any blank cells in column A and then in Column B
enters a trimmed version of column A's contents. SAVE your work before
testing this.

Sub tr()
Dim eRow As Long
eRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("A1:A" & eRow).SpecialCells(xlCellTypeBlanks).Delete
eRow = Cells(Rows.Count, 1).End(xlUp).Row
With Range("B1:B" & eRow)
.FormulaR1C1 = "=trim(rc[-1])"
.Value = .Value
End With
End Sub

Hope this helps
Rowan

wrote:
Ok, here is the code I currently have. I got some from on here, and
some,(the really slow part) is my first attempt at VBA. The changes I
need to make are as follows. The workbook contains sheets called 1, 2,
3, 4, 5, etc, all the way to 31. (seperate sheet for each day of the
month). I need this formula to work on the active sheet, no matter
which sheet it is on. The second problem is the speed of the DO UNTIL
loop. The 400 is there because I know that none of teh data that is
copied into the A column goes beyond 400 rows. Any help would eb
greatly appreciated

Sub test()
Call RemoveDuplicates("=")
Call tr
End Sub


Public Sub RemoveDuplicates(ByVal ReplaceCharacter As String)
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range


Set wks = Sheets("1")
Set rngToSearch = wks.Range("a:a")
Set rngFound = rngToSearch.Find(What:=ReplaceCharacter & _
ReplaceCharacter, LookAt:=xlPart)


Do While Not rngFound Is Nothing
rngToSearch.Replace What:=ReplaceCharacter, _
Replacement:=""
Set rngFound = rngToSearch.Find(What:=ReplaceCharacter & _
ReplaceCharacter, LookAt:=xlPart)
Loop
End Sub
Sub tr()
Dim i As Integer
i = 0
Do Until i = 400
i = i + 1
If Cells(i, 1) = "" Then Cells(i, 1).Delete
Cells(i, 2).Value = Application.Trim(Cells(i, 1))
Loop


End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default needs to run faster

Thanls, but this created even more problems and didn't run any faster.
Now all teh formulas are showing ref#

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
can this be done faster? Frank Excel Discussion (Misc queries) 7 August 9th 07 10:02 PM
Faster way to do this? Ed Excel Programming 1 November 14th 05 04:27 PM
Can faster CPU+larger/faster RAM significantly speed up recalulati jmk_li Excel Discussion (Misc queries) 2 September 28th 05 10:24 AM
Is there a faster way Jim May Excel Programming 3 September 19th 04 04:42 AM
Which one is faster? Syed Zeeshan Haider[_4_] Excel Programming 14 December 4th 03 05:28 PM


All times are GMT +1. The time now is 09:45 PM.

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"