Thread: Clean up code.
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dana Sherbondy[_2_] Dana Sherbondy[_2_] is offline
external usenet poster
 
Posts: 1
Default Clean up code.

Tim,

It looks like the line: Range("F"i"").Select
should be something like:
Range("F" & i).Select

This will set it to F3 or F81 or whatever the value of I
is so you can do your paste.

-----Original Message-----
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

.