jimrward
Well-known Member
- Joined
- Feb 24, 2003
- Messages
- 1,899
- Office Version
- 2021
- 2019
- 2016
- 2013
- 2011
- 2010
- 2007
- 2003 or older
- Platform
- Windows
having a senior moment here
I have a worksheet with loads of columns but I only want to use a couple in a bit of VBA code to generate a text file for another application
one of these is names, so i can easily select a number of names and run my VBA, 2 columns away is an ID marker that I also want to use so my portion of code thus far is for testing
Dim mynames() As Variant
mynames = Application.Selection.Value
um = UBound(mynames)
n1=mynames(1) FAILS
For Each MyName In mynames
fred = MyName
Next
myids = Application.Selection.Offset(0, 2)
For Each Myid In myids
fred = Myid
Next
i want to to create a loop for each name but also keep things in sync with the IDS
every time i try and reference the array I get a subscript error, if there are 5 names for example, i want to loop from 1 to 5, and be able to reference the elements of the arrays in my output
I have a worksheet with loads of columns but I only want to use a couple in a bit of VBA code to generate a text file for another application
one of these is names, so i can easily select a number of names and run my VBA, 2 columns away is an ID marker that I also want to use so my portion of code thus far is for testing
Dim mynames() As Variant
mynames = Application.Selection.Value
um = UBound(mynames)
n1=mynames(1) FAILS
For Each MyName In mynames
fred = MyName
Next
myids = Application.Selection.Offset(0, 2)
For Each Myid In myids
fred = Myid
Next
i want to to create a loop for each name but also keep things in sync with the IDS
every time i try and reference the array I get a subscript error, if there are 5 names for example, i want to loop from 1 to 5, and be able to reference the elements of the arrays in my output