Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Range("Variable") issue


Reply
 
Thread Tools Display Modes
  #1  
Old 10-01-2010, 10:56 AM
Touks Touks is offline
Newcomer
 
Join Date: Sep 2010
Posts: 12
Default Range("Variable") issue


Hello,
Im having an issue of going to a cell that my array holds,


Code:
'putting UserPromptTime  elements into array
Dim iX As Integer
For iX = 0 To (Len(UserPromptTime) - 1)
ColumnArray(iX) = Mid(UserPromptTime, iX + 1, 1)
Next
Now I'm trying to make it go to the cell that the full array is in eg if ZZ3

Code:
Range("ZZ3").select
I tried using the original var as well but no luck

range("userprompttime").select

no luck

any help is welcomed. Ty
Reply With Quote
  #2  
Old 10-01-2010, 11:31 AM
Gruff's Avatar
Gruff Gruff is online now
Bald Mountain Survivor

Super Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA
Posts: 5,877
Default

Kind of tough for us to guess what your sample value inside the string UserPromptTime is. (Assuming it is a string)

Is it numerical or letters?

Also you really should be using: "Optiion Explicit" at the top of your module.
...
The Cells() object has a bit more flexible input than the range object.
Examples:
sCol = "ZZ"
nRow = 3
Cells(nRow,sCol).Select
-or-
nCol = 41
nRow = 6
Cells(nRow,nCol).Select
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
  #3  
Old 10-01-2010, 12:02 PM
Touks Touks is offline
Newcomer
 
Join Date: Sep 2010
Posts: 12
Default

Yes userprompt i have as a string. basically i want to
if the input is 2 value eg A5

ColumnArray(0) gets A
ColumnArray(1) get 5

then I make it go to range("A5")

Code:
Sub UserPromptTimeStampLocation()
' Declaring TimeStamp Allocated Variables and prompting user for timestamp colunme
Dim UserPromptTime As String
UserPromptTime = InputBox("Please enter the TIME STAMP start Row and Column location e.g, A5")

' Declare array with length of userpromptTime
ReDim ColumnArray(Len(UserPromptTime))

'putting UserPromptTime  elements into array
Dim iX As Integer
For iX = 0 To (Len(UserPromptTime) - 1)
ColumnArray(iX) = Mid(UserPromptTime, iX + 1, 1)

Next

' putting the individual array into cells
Range("Z1").Value = ColumnArray(0)
Range("Z2").Value = ColumnArray(1)


' Go to R location Z2 and C location Z1
Range("columnarray(0)").Select<-----:( cant do this wish i could!
Reply With Quote
  #4  
Old 10-01-2010, 12:28 PM
Bob Phillips's Avatar
Bob Phillips Bob Phillips is offline
Contributor
 
Join Date: Jul 2009
Posts: 506
Default

Why put it in an array, just use the input

Code:
Range(UserPromptTime).Select
Reply With Quote
  #5  
Old 10-01-2010, 12:37 PM
Touks Touks is offline
Newcomer
 
Join Date: Sep 2010
Posts: 12
Default

TY for the help what i did was
Cells(ColumnArray(1), ColumnArray(0)).Select and it worked perfect

The funny weird thing is, I tried Range(UserPromptTime).Select and it refused to work for me. But After trying the method up top, it started working..

TY all for the help
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->