Closed Thread
Results 1 to 3 of 3

Problem with VB script (noob!)

  1. #1
    Registered User
    Join Date
    04-22-2009
    Location
    Doncaster, England
    MS-Off Ver
    365
    Posts
    38

    Problem with VB script (noob!)

    Hey all,
    Just trying to muster up a script for a spreadsheet at work,
    i have no skills in vb but by reading a few articles on the net i have managed to knock a script up that will automatically enter information into the adjacent cells when a referance number is put in.
    I expect the script maybe wrong but it actually works fine at the min. the problem been is that i need the script to runa on all pages and i need it to run on newly created worksheets.

    The script is as follows (i Have changed cell values due to it been personal data)


    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target = "E1" Then
    Target.Offset(, 1) = "Periodic Inspection & Survey"
    Target.Offset(, 2) = "195"
    End If

    If Target = "E2" Then
    Target.Offset(, 1) = "Rewire 1 Bed Bungalow"
    Target.Offset(, 2) = "2358"
    End If

    If Target = "E3" Then
    Target.Offset(, 1) = "Rewire 2 Bed Bungalow"
    Target.Offset(, 2) = "2478"
    End If

    If Target = "E4" Then
    Target.Offset(, 1) = "Rewire 3 Bed Bungalow"
    Target.Offset(, 2) = "2785"
    End If

    If Target = "E5" Then
    Target.Offset(, 1) = "Rewire 2 Bed House"
    Target.Offset(, 2) = "2900"
    End If

    If Target = "E6" Then
    Target.Offset(, 1) = "Rewire 3 Bed House"
    Target.Offset(, 2) = "3160"
    End If

    If Target = "E7" Then
    Target.Offset(, 1) = "Rewire 4 Bed House"
    Target.Offset(, 2) = "3240"

    End If




    If Intersect(Target, Range("A11:A29")) Is Nothing Then Exit Sub
    Application.EnableEvents = False
    Target = UCase(Target)
    Application.EnableEvents = True
    End Sub

    This is saved as the code for sheet 1

    when i open a new sheet it has no code

    i have tried saving this in the 'workbook' page but had no luck!

    it wont let me upload the file due to it been a xlsm filetype!

    im at my wits end! Please help!!
    Dan

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Problem with VB script (noob!)

    Welcome to the forum.

    Please take a few minutes to read the forum rules, and then amend your thread title to be descriptive, and add code tags to your code.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Problem with VB script (noob!)

    Thread closed.

Closed Thread

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