Thread: Clean up code.
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 408
Default Clean up code.

I am a basic excel user and here is my macro. I am trying to set whatever
sheet is open as the active sheet, pick a cell from that sheet value equal to
LL-CP-0100 and assign a variable to the number part ie 0100. My such variable
is "j" below. I also set a variable i which should equal j+1. Then i want to
use i and j in the code as shown below. Can someone help clean the code.

' Macro recorded 9/30/2004 by Husky User
'


Sub Atester()
Dim sStr As String
Dim pos As Long
Dim i As Long
Dim j As Long
Windows"current sheet".Activate
Range("J2").Select
sStr = "J2"
pos = InStrRev(sStr, "-")
i = Mid(sStr, pos + 1) + 1
j = i - 1
MsgBox i
MsgBox j

Windows("LL-CP-j.xls").Activate
Range("F3:H3").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Completions LL Register 2004-09-030.xls").Activate
Range("F"i"").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End Sub