+ Reply to Thread
Results 1 to 2 of 2

'Insert New Row' VBA script working in one sheet, but not another

  1. #1
    Registered User
    Join Date
    02-09-2015
    Location
    London
    MS-Off Ver
    2013
    Posts
    92

    'Insert New Row' VBA script working in one sheet, but not another

    I have a button in 'Sheet A' that has a macro assigned to it, which adds a new row at the bottom of a series of data. The code is:


    Sub SheetAa_NewRow()
    Dim varUserInput As Variant
    varUserInput = InputBox("Enter Row Number where you want to add a record:", _
    "What Row?")
    If varUserInput = "" Then Exit Sub

    RowNum = varUserInput
    Rows(RowNum & ":" & RowNum).Insert Shift:=xlDown
    Rows(RowNum - 1 & ":" & RowNum - 1).Copy Range("A" & RowNum)
    Range(RowNum & ":" & RowNum).ClearContents
    End Sub

    This code sits in 'Module 12'.

    I have another sheet, 'Sheet B', which has a similar series of data in it. I want to add a similar button which performs the same function, using the same code. I have put the code in 'Module 17', and assigned the macro, but it keeps trying to mess with the data series in 'Sheet A.'

    Could you someone explain to me why this is? I suspect I'm misunderstanding something fundamental about modules/sheets and VBA - Any advice would be a great help.

    Thanks

  2. #2
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: 'Insert New Row' VBA script working in one sheet, but not another

    Hi Shaunguyver,

    CAn you please attach the excel file here.. will update the code accordingly
    Regards
    Parth

    I appreciate your feedback. Hit * if u Like.
    Rules - http://www.excelforum.com/forum-rule...rum-rules.html

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VB script not working
    By ssschaar in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-04-2014, 03:28 PM
  2. [SOLVED] Disable Insert Sheet function - NOT Working
    By JJFletcher in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-03-2014, 06:27 AM
  3. Script to open, search, and insert the hyperlinked location file as a new sheet
    By kurtman1859 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-10-2013, 12:29 PM
  4. This script isn't working, why not?
    By ledworld in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-18-2013, 06:04 PM
  5. [SOLVED] my if-then-else script is not working
    By dschmitt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2013, 02:24 AM

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