LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Trying to work with User-selected non-contiguous ranges


Evening all,

As always what I thought would be a nice bit of mental exercise has
evolved into some monster that delights in my frustration and on-coming
headache:( .

What my little bit of code is trying to do is as follows:

1. The user selects the cells (using the standard Ctrl button and
mouse-click method) which are to be printed in a pre-constructed labels
document in Word

2. The code executes when a control button is activated and registers
the selected cells as an array using the selection object(?) and then
cycles through the array members adding each to its own label in the
document.

Does that make any sense?
Basically I'm trying to turn selected cells into an array and process
them that way.

Well, to my delight:) the code worked perfectly until I tried
selecting just one cell (i.e. one record) to print.
It seems that VBA won't recognise one-selected cell as an array .
Further testing proved that a non-contiguous selection of cells also
won't be recognised as an array .

I'm at a bit of a loss now and its not a facility I can do without.
Any help will be greatly appreciated.

Thanks Tris

Selection of code below:

Private Sub CommandButton1_Click()

Dim Outputs As Variant

Dim i As Integer

Record_a = Selection.Value

Dim Word As Word.Application
Set Word = New Word.Application

With Word
..ScreenUpdating = False
..Documents.Open Filename:="C:\Documents and
Settings\Label1.doc"
..Visible = True

For i = LBound(Record_a) To UBound(Record_a)
With .Selection
..TypeText Text:=Record_a(i, 1)
..MoveRight unit:=wdCell, Count:=1
End With
Next i

..ScreenUpdating = True

End With

Set Word = Nothing
End Sub


--
Tristan
------------------------------------------------------------------------
Tristan's Profile: http://www.excelforum.com/member.php...o&userid=34061
View this thread: http://www.excelforum.com/showthread...hreadid=541967

 
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
Add Permission did not work in "Allow User to Edit Ranges" hsinlin58 Excel Discussion (Misc queries) 0 May 22nd 06 03:10 PM
Delete non-contiguous selected rows Barbara Ryan Excel Programming 8 May 9th 06 08:58 PM
summing non contiguous ranges valaor Excel Discussion (Misc queries) 6 March 22nd 06 04:17 PM
Adding Non-Contiguous Ranges COE Excel Discussion (Misc queries) 11 January 24th 06 11:43 PM
Delete a selected area from a non-contiguous range Paul Martin Excel Programming 3 September 11th 05 01:31 AM


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