LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 313
Default Write record from Form to new row in spreadsheet

Not sure if my first one went through okay.

I am using a form to provide input into a spreadsheet. Every time I write a
record, I want it to write to a new line in the spreadsheet. When I first
used this code, it wrote on the second line in the spreadsheet, even though
there was a second header line there and it overwrote the line. When I took
out the first header, it wrote on the second line okay. However, when I tried
to enter a new record, it overwrote the first record.

Basically I want to write the first new record on the third line (after two
header lines) and then each new record on the next available line, etc. Below
is the code I am using. Can you someone help me out here?

Private Sub CommandButton8_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Master")
Dim nextrow As Long

'find first empty row in database
With Worksheets("Master")
nextrow = .Range("p65536").End(xlUp).Row + 1
End With
'check to see if there's room
If nextrow = 6589 Then
MsgBox "out of room!"
Exit Sub
End If
With Worksheets("Master")
.Cells(nextrow, 1).Value = InquiryDate
.Cells(nextrow, 2).Value = DatabaseAccessed
.Cells(nextrow, 3).Value = Requestor
.Cells(nextrow, 4).Value = AccountAccessed
.Cells(nextrow, 5).Value = RequestReason
.Cells(nextrow, 6).Value = InformationRequested
.Cells(nextrow, 7).Value = Comments
End With
End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Write record from Form to new row in spreadsheet Tony Excel Discussion (Misc queries) 1 March 18th 10 02:43 PM
record update VBA form Roy Gudgeon[_2_] Excel Discussion (Misc queries) 0 March 15th 10 04:27 PM
Control on a form to find a record Terry Excel Discussion (Misc queries) 2 September 7th 08 03:04 PM
Can I record or write a macro to send a worksheet via Outlook? Catherine Excel Discussion (Misc queries) 1 September 14th 05 04:15 AM
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM


All times are GMT +1. The time now is 08:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"