Wrong Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Guest
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??
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
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,
 
Upvote 0
Hi Barrie,
Tried that, doesn't seem to work... when I am in break mode.. it says LastCell = nothing
 
Upvote 0

Forum statistics

Threads
1,223,382
Messages
6,171,767
Members
452,422
Latest member
rlynchbro

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top