Results 1 to 3 of 3

Code to use a varible integer inside a formula in VBA

Threaded View

westonkw Code to use a varible integer... 02-28-2008, 11:49 AM
Leith Ross Hello westonkw, The... 02-28-2008, 02:26 PM
westonkw thanks I used ShtName =... 02-28-2008, 04:19 PM
  1. #1
    Registered User
    Join Date
    02-28-2008
    Posts
    36

    Code to use a varible integer inside a formula in VBA

    I am working on a workbook that has a summary sheet. The original workbook was created with 40 sheets that were linked back to the summary sheet. I have changed the workbook so there are only 5 sheets to start out with, but have created a macro to add an additional sheet if needed. This way there isnt a bunch of empty sheets when the project is finished. The problem I am having is with the summary sheet. All of the cells come up with a ref error because the sheet that the cell was originally linked to has been deleted. I need to create a macro that will adjust the cell to the name of the sheet that is created with the macro. I think this should be easy because the names of the sheets that are being added are just 6, 7, 8, and so on, so if I could figure out how use a varible integer inside a formula in vb i could loop it through the cells and get it to work, but Im having a heck of a time using these integers. Here is an example of the formula in vb i need.

    Range("b15").Select
         ActiveCell.FormulaR1C1 = "='8'!R3C[18]"
    I need the red 8 to be a variable integer such as "x" that would be based on the sheet count.

    Thanks any help is appreciated
    Last edited by VBA Noob; 02-28-2008 at 01:24 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1