Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am attempting to assign paragraphs in a word document based on the
named ranges in an excel workbook (sheet level names, named sequentially). I want to iterate through the names, and when one does not exist, move to another set of names. I have tried the following in word's VBE: .................................................. ...... Dim i as integer, j as Integer Dim strCell as String Dim rng as Range Set myWB = GetObject({path}file.xls) Do Until j10 strCell = myWB.Sheets(i).Name & "!somename" & j On Error Resume Next Set rng = Range(strCell) If rng Is Nothing Then MsgBox "Range is Nothing" Exit Do Else 'procedure to assign & place paragraphs End If j = j+1 Loop .................................................. ...... Assuming that strCell is a valid name (which I think it is, b/c that part of the code works when I tried it in Excel's VBE) and exists in myWB, why won't rng set to Range(strCell)? Any suggestions for amending the Set rng = Range(strCell) command so this will work? Any other thoughts? I'm lost. All help would be greatly appreciated, Petur G PS- The code would be simpler if I could use a For Each loop, but I don't want to loop through every name in the worksheet. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Declaring a tab name as a variable | Excel Programming | |||
Declaring a tab name as a variable | Excel Programming | |||
Declaring a Public variable as a Range and its lifetime | Excel Programming | |||
Declaring Variable as VBConstant | Excel Programming | |||
Declaring a variable? | Excel Programming |