Wrong Code

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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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,213,581
Messages
6,114,466
Members
448,574
Latest member
bestresearch

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