LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Range issue

This macro used to work correctly. Now that the rows have increased to over
33,000. The macro no longer execute the last command of splitting the last
two coulombs. Any help would be appreciated.

Public Sub DeDash()

Dim iNumRows As Integer
Dim i As Integer
Dim j As Integer

On Error Resume Next

With ThisWorkbook.Sheets(1)

' Delete columns A, B, C, G and H
.Range("A:C,G:H").Delete Shift:=xlToLeft

' Align left columns A, B and C
.Columns("A:C").HorizontalAlignment = xlLeft

' Autofit columns A, B and C
.Columns("A:C").EntireColumn.AutoFit

iNumRows = .Range("A1").CurrentRegion.Rows.Count
For i = 1 To iNumRows

' Replace dash with space in columns A and B
.Cells(i, 1).Value = Trim(Replace(.Cells(i, 1).Value, "-", " "))
.Cells(i, 2).Value = Trim(Replace(.Cells(i, 2).Value, "-", " "))

' Split column C on dash
j = InStr(1, .Cells(i, 3).Value, "-")
If j < 0 Then
.Cells(i, 4).Value = Mid(.Cells(i, 3).Value, j + 1)
.Cells(i, 3).Value = Left(.Cells(i, 3).Value, j - 1)
End If

Next i

' Delete first row
.Rows("1:1").Delete Shift:=xlUp

End With

End Sub


 
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
Range Issue Arturo Excel Programming 4 February 5th 07 10:57 PM
Range Name issue Barb Reinhardt Excel Programming 5 September 8th 06 04:59 PM
Loop through range issue Kieran[_55_] Excel Programming 6 August 25th 06 10:15 PM
Range issue evil baby[_13_] Excel Programming 3 March 7th 06 03:59 PM
Range issue... James Excel Programming 4 August 4th 05 09:26 PM


All times are GMT +1. The time now is 12:42 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"