Thanks Thanks:  0
Likes Likes:  0
Results 1 to 6 of 6

Thread: Wrong Code

  1. #1
    Guest

    Default

    Hi all
    Sub WriteTable(SheetName As String, Details As FormDetail)

    Dim DBTableLocation As Object, LastCell As Range

    Worksheets(SheetName).Activate

    ' Find the last cell in a column
    LastCell = Range("A65536").End(xlUp).Select

    With LastCell
    .FormulaR1C1 = Details.AccountNumber
    .Offset(0, 1).FormulaR1C1 = Details.Bucket
    .Offset(0, 2).FormulaR1C1 = Details.Claimable
    .Offset(0, 3).FormulaR1C1 = Details.CollectAmount
    .Offset(0, 4).FormulaR1C1 = Details.PushBack
    .Offset(0, 5).FormulaR1C1 = Details.SV_Code
    .Offset(0, 6).FormulaR1C1 = Details.SV_Name
    End With

    End Sub

    When I run the code.. I get LastCell object not set. What's wrong with the code??

  2. #2
    MrExcel MVP Barrie Davidson's Avatar
    Join Date
    Feb 2002
    Location
    Winnipeg
    Posts
    2,330
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-03-05 19:10, Anonymous wrote:
    Hi all
    Sub WriteTable(SheetName As String, Details As FormDetail)

    Dim DBTableLocation As Object, LastCell As Range

    Worksheets(SheetName).Activate

    ' Find the last cell in a column
    LastCell = Range("A65536").End(xlUp).Select

    With LastCell
    .FormulaR1C1 = Details.AccountNumber
    .Offset(0, 1).FormulaR1C1 = Details.Bucket
    .Offset(0, 2).FormulaR1C1 = Details.Claimable
    .Offset(0, 3).FormulaR1C1 = Details.CollectAmount
    .Offset(0, 4).FormulaR1C1 = Details.PushBack
    .Offset(0, 5).FormulaR1C1 = Details.SV_Code
    .Offset(0, 6).FormulaR1C1 = Details.SV_Name
    End With

    End Sub

    When I run the code.. I get LastCell object not set. What's wrong with the code??
    If I'm not mistaken, change:
    ' Find the last cell in a column
    LastCell = Range("A65536").End(xlUp).Select

    to

    ' Find the last cell in a column
    LastCell = Range("A65536").End(xlUp)

    Regards,

    Barrie Davidson

    "You're only given a little spark of madness. You mustn't lose it." - Robin Williams

  3. #3
    Guest

    Default

    Hi Barrie,
    Tried that, doesn't seem to work... when I am in break mode.. it says LastCell = nothing

  4. #4
    Guest

    Default

    Set LastCell = Range("A65536").End(xlUp)

  5. #5
    MrExcel MVP Barrie Davidson's Avatar
    Join Date
    Feb 2002
    Location
    Winnipeg
    Posts
    2,330
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-03-05 19:29, Anonymous wrote:
    Set LastCell = Range("A65536").End(xlUp)
    Good catch Anonymous whoever you are
    Barrie Davidson

    "You're only given a little spark of madness. You mustn't lose it." - Robin Williams

  6. #6
    Guest

    Default

    Thank you.... I am an idiot!!

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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