Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ah, the fun continues. I really ought to buy the VBA power programming
book or something. So here's the current issue. I have a sub in a module that is public and a command button in a user form that is private, as below. The cmdPlaceXcells button is clicked after some cells are selected in worksheets(2) Private Sub cmdPlaceXcells_Click() Dim rngeSelected As Range Set rngeSelected = ActiveWindow.RangeSelection Dim aryOfRanges() As Range 'for placing pictures in Dim maxAryOfRanges As Integer Dim cell As Range maxArrOfRanges = 0 'Insert X in each selected cell. Add each selected cell _ ' to the aryOfRanges For Each cell In rngeSelected maxOfAryOfRanges = maxAryOfRanges + 1 cell.Formula = "X" ReDim Preserve aryOfRanges(1 To maxAryOfRanges) Set aryOfRanges(maxArrayOfRanges) = cell Next cell TestPictureInsert (aryOfRanges()) End Sub Public Sub TestPictureInsert(arrayOfRanges() As Range) Set picQCAnormal = _ ThisWorkbook.Worksheets("Variables").Pictures("Pic ture 158") 'declarations Dim rnge As Range Dim pic As Picture For Each rnge In arrayOfRanges.Cells With rnge.Parent 'worksheets(2) picQCAnormal.Copy .Paste Set pic = .Pictures(.Pictures.Count) 'the one just pasted End With With pic .Top = rnge.Top .Left = rnge.Left .Width = rnge.Width .Height = rnge.Height .Name = "Pic_" & rnge.Address(ReferenceStyle:=xlR1C1) End With Next rnge End Sub I am quite sure the picture inserting works correctly. I get an error that states "array or user-defined type expected". Any suggestions?? Thanks, Abe |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Array formula: how to join 2 ranges together to form one array? | Excel Worksheet Functions | |||
Wrong Numerical Input | Excel Discussion (Misc queries) | |||
histogram, wrong input range | Excel Discussion (Misc queries) | |||
How do I add input data in the input ranges in drop down boxes. | Excel Discussion (Misc queries) | |||
variant array containing cel adresses convert to actual ranges-array | Excel Programming |