Option Explicit Sub assignArray() '''''''''''''''''''''Declaring an Array With Dim Statement Dim Arr(7) Arr(1) = "Monday" Arr(2) = "Tuesday" Arr(3) = "Wednesday" Arr(4) = "Thursday" Arr(5) = "Friday" Arr(6) = "Saturday" Arr(7) = "Sunday" MsgBox Arr(1) & "-" & Arr(2) & "-" & Arr(3) & "-" & Arr(4) & "-" & Arr(5)
End Sub '''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 'By declaring a dynamic array ', you can size the array while the 'code is running. Use a Static, Dim, 'Private, or Public statement to declare an array, 'leaving the parentheses empty, as shown in the 'following example. 'Dim sngArray() As Single '''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub arrayTest() '''''''''''''''Sample programe to have dynamic array '''''''''''''''User Can Give the range of Array in inputbox MsgBox "INPUT STRING1 WILL BE START FROM D2" Dim i As Integer Dim intMyScores() As Integer Dim intArraySize As Integer intArraySize = InputBox("How many scores are you entering?", "Array Size") ReDim intMyScores(1 To intArraySize) For i = 1 To intArraySize intMyScores(i) = InputBox("Enter number " & i, "Static Array Test") Next For i = 1 To intArraySize Debug.Print "For array element " & i & " the number is " & intMyScores(i) MsgBox "For array element " & i & " the number is " & intMyScores(i) Worksheets("Sheet1").Range("C2").Activate ActiveCell.Offset(rowOffset:=0, columnOffset:=i).Value = intMyScores(i) Next End Sub Sub arrayTest1() '''''''''''''''Sample programe to have dynamic array '''''''''''''''User Can Give the range of Array in inputbox MsgBox "INPUT STRING2 WILL BE START FROM D3" Dim i1 As Integer Dim intMyScores1() As Integer Dim intArraySize1 As Integer intArraySize1 = InputBox("How many scores are you entering?", "Array Size") ReDim intMyScores1(1 To intArraySize1) For i1 = 1 To intArraySize1 intMyScores1(i1) = InputBox("Enter number " & i1, "Static Array Test") Next For i1 = 1 To intArraySize1 Debug.Print "For array element " & i1 & " the number is " & intMyScores1(i1) MsgBox "For array element " & i1 & " the number is " & intMyScores1(i1) Worksheets("Sheet1").Range("C2").Activate ActiveCell.Offset(rowOffset:=1, columnOffset:=i1).Value = intMyScores1(i1) Next End Sub ''''''''''''''''''''''''''''''''dear michal you can take user input into array '''''''''''''''''''''''''''''then you can use perform subtraction ''''''''''''''''''''''''''''hope it will help happy to help :) shyam On Tue, Mar 2, 2010 at 1:15 AM, JAW-UC <jer...@avenue-two.com> wrote: > Hello group! > > I'm relatively new to VBA. I'm trying to build an array by taking the > string to the left of each semicolon (or to the right after the final > semicolon) in each cell in a particular column from a data import and > placing this string in the array as a value, rather than importing the > data as semicolon-separated values. Does anyone have a suggestion as > to how to write the code for this? Thanks... > > -- > > ---------------------------------------------------------------------------------- > Some important links for excel users: > 1. Follow us on TWITTER for tips tricks and links : > http://twitter.com/exceldailytip > 2. Join our Facebook Group @ > http://www.facebook.com/group.php?gid=287779555678 > 3. Excel tutorials at http://www.excel-macros.blogspot.com > 4. Learn VBA Macros at http://www.quickvba.blogspot.com > 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com > > To post to this group, send email to excel-macros@googlegroups.com > > <><><><><><><><><><><><><><><><><><><><><><> > HELP US GROW !! > > We reach over 6,800 subscribers worldwide and receive many nice notes about > the learning and support from the group.Let friends and co-workers know they > can subscribe to group at > http://groups.google.com/group/excel-macros/subscribe > -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our Facebook Group @ http://www.facebook.com/group.php?gid=287779555678 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> HELP US GROW !! We reach over 6,800 subscribers worldwide and receive many nice notes about the learning and support from the group.Let friends and co-workers know they can subscribe to group at http://groups.google.com/group/excel-macros/subscribe