Subscript out of range

mtchagoue

New Member
Joined
Sep 12, 2011
Messages
7
Hi All,

i have few concern on VBa your help will be really appreciated .

1/

I have this code:

Dim myWB As Excel.Workbook

Private Sub CommandButton1_Click()
Set myWB = GetObject("N:\General Office\EMC\Misc\R&D - Ideas- Test concepts\Test\New LIS 2011v2 + Moving Checklist.xlsm")
Selection.GoTo What:=wdGoToBookmark, Name:="Landlord"
Selection.TypeText (myWB.Sheets("LEASE_INFORMATION").Range("Partnership:"))
Set myWB = Nothing
Set myWB = GetObject("N:\General Office\EMC\Misc\R&D - Ideas- Test concepts\Test\New LIS 2011v2 + Moving Checklist.xlsm")
Selection.GoTo What:=wdGoToBookmark, Name:="Tenant"
Selection.TypeText (myWB.Sheets("LEASE INFORMATION").Range("Company Name"))
Set myWB = Nothing
End Sub

that iam trying to run but i have the error message "Subscript out of range" and when i went back on the specific range (in Excel) it is "merger and center'" with other ranges. is it the ranges the issues?if yes how can i solve the problem please? if not what is the issue and how can i solve it?


2/ Let assume the same code above, is there a way how i can spread the "Tenant " and "Landlord " in all my document (WORD Doc. - approximately 10 pages) without repeating the code every time


Thank you Very much!!!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Are you running this code from Word?
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,285
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top