+ Reply to Thread
Results 1 to 2 of 2

Run-time error '1004' ?

Hybrid View

  1. #1
    Registered User
    Join Date
    04-16-2010
    Location
    High Wycombe, England
    MS-Off Ver
    Excel 2003
    Posts
    4

    Run-time error '1004' ?

    HI there on the code below I am getting run-time error 1004 whenever it reaches
    Range("A3").Select

    Please help


    Sub UpdateBtn_Click()
     
        Sheets("Data").Select
        
        Dim NewMGRate As Double
        NewMGRate = InputBox("Enter today's MG Rate")
        Range("A3").Select
        Selection.End(xlToRight).Select
        ActiveCell.Offset(0, 1).Value = NewMGRate   
        
    End Sub
    Last edited by sonyidicula; 05-14-2010 at 05:43 AM.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Run-time error '1004' ?

    Try with this macro:
    Sub UpdateBtn_Click()
        Dim shData As Worksheet
        Set shData = ThisWorkbook.Sheets("Data")
        shData.Select
        
        Dim NewMGRate As Double
        NewMGRate = InputBox("Enter today's MG Rate")
        shData.Range("A3").Select
        Selection.End(xlToRight).Select
        ActiveCell.Offset(0, 1).Value = NewMGRate
    End Sub
    or, better, with this:
    Sub UpdateBtn_Click()
        Dim sh As Worksheet
        
        Set sh = ThisWorkbook.Sheets("Data")
        sh.Select
        Dim NewMGRate As Double
        
        NewMGRate = InputBox("Enter today's MG Rate")
        myCol = sh.Range("A3").End(xlToRight).Offset(0, 1).Column
        sh.Cells(3, myCol) = NewMGRate
    End Sub
    Regards,
    Antonio

+ Reply to 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