+ Post New Thread
Results 1 to 5 of 5
Office Software Thread, Excel VB Help in Technical; ...
  1. #1
    knightrider's Avatar
    Join Date
    Mar 2006
    Location
    Leeds
    Posts
    85
    Thank Post
    18
    Thanked 10 Times in 7 Posts
    Rep Power
    19

    Excel VB Help

    Morning,

    I am trying to get a field on a excel file to increase each time the file is opened.

    Attached is the file and I have tried inserting the following code into it.

    Private Sub Workbook_Open()
    Range("F3").Value = 1 + Range("F3").Value
    End Sub



    This I thought would increase the value of the cell by 1 each time the file is opened. However this isn't working and i have no idea why. I am literally ripping my hair out over this. I'm sure itís really simple to do.

    Any help much much appreciated.

    Knightrider
    Attached Files Attached Files

  2. #2

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,819
    Thank Post
    110
    Thanked 589 Times in 510 Posts
    Blog Entries
    1
    Rep Power
    226
    I think you have to reference the worksheet too?

    Code:
    Worksheets("Sheet1").Range("A1").Value = Worksheets("Sheet1").Range("A1").Value + 1

  3. #3

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,731
    Thank Post
    344
    Thanked 520 Times in 488 Posts
    Rep Power
    180
    There's your issue "Master1.xlsx"

    That's not a macro enabled file. It'll need to be a .xlsm

    Just tested it and

    Code:
    Private Sub Workbook_Open()
    Range("F3").Value = Range("F3").Value + 1
    End Sub
    In my test.xlsm using "Thisworkbook" and it works fine

    Steve
    Last edited by Steve21; 14th November 2012 at 10:11 AM.

  4. #4

    Join Date
    Nov 2007
    Location
    Rotherham
    Posts
    1,678
    Thank Post
    122
    Thanked 126 Times in 102 Posts
    Rep Power
    46
    I've copied your code into a workbook and it runs OK.

    How about changing the name of the Sub to "AutoOpen" so it runs everytime it runs when the workbook opens. Possibly change it to an xlsm file which is what I've saved it as?

    Blast beaten too it!
    Last edited by Stuart_C; 14th November 2012 at 10:13 AM.

  5. #5
    knightrider's Avatar
    Join Date
    Mar 2006
    Location
    Leeds
    Posts
    85
    Thank Post
    18
    Thanked 10 Times in 7 Posts
    Rep Power
    19
    Thanks- got it working!

SHARE:
+ Post New Thread

Similar Threads

  1. A little .vbs help please
    By ozzy in forum Scripts
    Replies: 9
    Last Post: 27th February 2009, 08:07 AM
  2. excel formula help again please
    By RabbieBurns in forum Windows
    Replies: 2
    Last Post: 13th August 2008, 05:31 PM
  3. small vbs help please
    By RabbieBurns in forum Scripts
    Replies: 4
    Last Post: 20th May 2008, 03:30 PM
  4. Covert CMD/BAT files to vbs help
    By tosca925 in forum Scripts
    Replies: 12
    Last Post: 8th November 2007, 02:58 PM
  5. Excel Formula Help
    By DSapseid in forum Windows
    Replies: 4
    Last Post: 7th November 2007, 04:56 PM

Thread Information

Users Browsing this Thread

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

Posting Permissions

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