Dear Excel Expert,
I created the following macro to run on a selected range, but if I select for example five cells in a column the macro does not stop at the fifth selection but continues to the very end of the list. I arbitrarily set the do until to .1 because I did not want the "do loop" to stop the macro but rather the other loop to stop it. I think this might be the problem though. And sometimes the macro doesn't run at all but gives me a Run-Time error - 6 - overflow.
Please help. Thanks Andrew
![]()
Sub Test8() ' ' Test8 Macro ' Macro recorded 4/25/2013 by . ' ' Keyboard Shortcut: Ctrl+Shift+Z ' 'This part is from "Variable Range and Input box" located in the folder 'Running a Macro on range(this is the folders approx. name) Dim myRange As Range Set myRange = Application.InputBox(Prompt:= _ "Please Select a Range", _ Title:="InputBox Method", Type:=8) If myRange Is Nothing Then ' Range is blank Else myRange.Select End If 'The following is the loop part. This is from, "Create a loop". This is 'document with the accompaning excel wk with multiple loops. ' This loop repeats a fixed number of times getting its reference from elsewhere Dim i As Integer Dim intRowCount As Integer intRowCount = myRange.CurrentRegion.Rows.Count For i = 1 To intRowCount 'The nested part is a loop to perform the macro. It is also in the 'document, "Create a loop" but it is not the same author. It is a 'separate author. 'Here is my macro to format the cell 'Print ActiveCell.Characters.Count With ActiveCell.Characters(1).Font 'counts 1 character over 'from the left, then seclects that cell and the next cell .Color = RGB(0, 0, 0) ' black End With 'Print ActiveCell.Characters.Count With ActiveCell.Characters(2).Font 'counts 2 characters from left ' to right and then below it is colored. .Color = RGB(0, 0, 255) End With With Selection.Interior .ColorIndex = 8 .Pattern = xlSolid .PatternColorIndex = xlAutomatic End With ActiveCell.Offset(1, 0).Select Next i 'This is end part of the loop End Sub











LinkBack URL
About LinkBacks
Register To Reply

Bookmarks