• 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.

How to create a VBA script for inserting new records in a worksheet?

Dear all,


Im working on a macro to type in certain information in a sheet by input boxes (see code below). Thing is that a want the macro to fill in the data below the last record. So the first it should insert info in a1, b1, c1 and next time in a2, b2, c2 etc…

Can anybody tell me how I can achieve this in VBA?


Thanks!


Regards,


Marc


Sub kaarten()


'macro om kaarten in te voeren en dan te laten berekenen wat je voor kansen je hebt tegen een bepaalde range


Dim inputkaarten As String

Dim range As Integer

Dim outputkaarten As String


Set ws = Worksheets("Blad1")


inputkaarten = InputBox("Voer hier je kaarten in")

ws.Cells(2, 4) = inputkaarten


range = InputBox("Voer hier de geschatte range van je tegenstander in")

ws.Cells(2, 5) = range


outputkaarten = ws.Cells(2, 6)


MsgBox (outputkaarten)


End Sub
 
Hi Marc ,


I assume your language is Dutch ; I cannot code in Dutch , so I can only point to the following links which may help :


http://www.rondebruin.nl/last.htm


describes how to code to look for the last row in a particular column or range.


You need to find out the last row of data in your sheet , and then offset it by 1 to go to a blank row. If you are starting off with a blank worksheet , the last row will be 1 , and you can skip the offsetting part. Use this row to store new data.


Narayan
 
Back
Top