• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA code works in one sheet not in this one

Hello,
I have a vba code that has to fill in certain cells on certain times. It works fine on a example file but not in this file, and I do not know why, can somebody please advice?
File included
 

Attachments

  • exceltest.xlsm
    24.7 KB · Views: 5
Can you also upload example file as well? It'd make comparison easier.

My guess. In the example file, data isn't stored in table. If you check lastrow variable, it's at the end of the table and not last cell with data in the column.
 
Hello,Thank you your fast reply, you are right, the example is not in a table, is there a way to adjust the code or do i have to change the table setup
the sample included
 

Attachments

  • macro\'s op tijd.xlsb
    21.5 KB · Views: 2
Sure. You need to change the code to something like below. Using dotchie_945() as example.
Code:
Sub dotchie_945()
Dim lastrow As Long
lastrow = Sheets("Tijdenaantallen").Range("I:I").Find("*", _
    SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Cells(lastrow + 1, "C").Value = Sheets("webquery_aantallen").Range("Y30").Value
End Sub
 
Back
Top