LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Concatanate variable name

Hi choco140,

You can't concatenate variable names directly, as VBA will not understand
it. You can, however, work with the Controls collection to do this:

Dim i As Integer

For i = 1 To 4
Me.Controls("Date" & CStr(i)).Text = _
Sheets("Sheet1").Cells(i, 1).Value
Next i

--
Regards,

Jake Marx
www.longhead.com


choco140 wrote:
I got four control on an userform named Date1, Date2, Date3 and Date4.
I am trying to fill them in with this small macro, it doesn't work
because my concatenation doesn't seem to be properly set up...

Sub Test
For i = 1 to 4
Date & i &.value = Range("A" & i).Value
Next i
End Sub

I got an error for "Date & i &.value", any idea how to solve this?

Thanks.


 
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
CONCATANATE nlogan Excel Worksheet Functions 3 May 27th 10 10:29 PM
Runtime Error '91' Object variable or With block variable not set Alec Coliver Excel Discussion (Misc queries) 2 October 24th 09 02:29 PM
variable height variable width stacked bar charts ambthiru Charts and Charting in Excel 3 January 18th 06 11:41 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
Formatting range in concatanate Nigel Excel Discussion (Misc queries) 3 April 28th 05 12:02 PM


All times are GMT +1. The time now is 03:03 AM.

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"