LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 408
Default assign variable

Thanks Norman heres what i have but it is not coded correct, here is what i
am trying to do thinking i = # and j = # -1 and what is "MsgBox i".

' 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

"Norman Jones" wrote:

Hi Tim,

As Bob indicates, I mis-read your data. Given that the required numeric
string follows the second hyphen character in your data, the InsrRev
function should be used. The suggested macro thus becomes:

Sub Atester()
Dim sStr As String
Dim pos As Long
Dim i As Long

sStr = "CP - 163"
pos = InStrRev(sStr, "-")
i = Mid(sStr, pos + 1) + 1
MsgBox i

End Sub


---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Tim.

One way:

Sub Atester()
Dim sStr As String
Dim pos As Long
Dim i As Long

sStr = "CP - 163"
pos = InStr(sStr, "-")
i = Mid(sStr, pos + 1) + 1
MsgBox i
End Sub

---
Regards,
Norman



"Tim" wrote in message
...
If a cell in a sheet is "LL-CP-0163" how can i set a variable in a macro
equal to 0163 or the number part of that cell. also how can i set another
variable equal to 0164 or the previous variable + 1








 
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
Assign value to a variable name Gnarlodious Excel Discussion (Misc queries) 2 August 20th 06 07:10 AM
Assign value to variable rroach Excel Discussion (Misc queries) 1 July 13th 05 05:24 AM
Variable VB to assign new sheet name Kevin M Excel Worksheet Functions 0 June 17th 05 12:15 AM
Sum Cells and assign to variable Kitty Excel Programming 2 September 16th 04 08:42 PM
VBA routine to assign first name only to a variable fitful_thought Excel Programming 6 August 3rd 04 01:39 PM


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