Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default VB code to fill next available cell

I have two different workbooks, a test book and a results book. I would like
to have a command button, that when clicked, opens the results workbook and
fill the users name and answers in the appropriate columns, say A1 through
G1. Then it saves the results workbook, closes it, and clears the contents of
the cells in the test workbook that contains the answers the user selected.
Then when someone else takes the test and does the same thing, their answers
are saved BELOW the first person in the results workbook, allowing me to use
the same test workbook and log everyone's results n the same workbook. I know
how to call open a new workbook, save and close it, and clear the contents,
but what I don't know is how to get the second or third or fourth users
answers to be entered in the row below the person before them. Hope this
makes sense and someone can help. Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,805
Default VB code to fill next available cell

The following code fragment will give you the last row used, in Col A, on
Data Sheet
in the variable LastRow... Add 1 to it and write to that row...
Dim LastRow As Long

With Worksheets("Data")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

End With
MsgBox LastRow

"GLHEC-BLS" wrote:

I have two different workbooks, a test book and a results book. I would like
to have a command button, that when clicked, opens the results workbook and
fill the users name and answers in the appropriate columns, say A1 through
G1. Then it saves the results workbook, closes it, and clears the contents of
the cells in the test workbook that contains the answers the user selected.
Then when someone else takes the test and does the same thing, their answers
are saved BELOW the first person in the results workbook, allowing me to use
the same test workbook and log everyone's results n the same workbook. I know
how to call open a new workbook, save and close it, and clear the contents,
but what I don't know is how to get the second or third or fourth users
answers to be entered in the row below the person before them. Hope this
makes sense and someone can help. Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default VB code to fill next available cell

That works great, but I don't understand the last part about adding 1. I
understand this is supose to tak eit to the row below the one with the last
entry, but I'm not sure where you mean to add the + 1 to the variable
LastRow. This is what I have right now.

Private Sub Worksheet_Activate()
Dim LastRow As Long

With Worksheets("Learning Style")
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Select

End With

End Sub

"Sheeloo" wrote:

The following code fragment will give you the last row used, in Col A, on
Data Sheet
in the variable LastRow... Add 1 to it and write to that row...
Dim LastRow As Long

With Worksheets("Data")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

End With
MsgBox LastRow

"GLHEC-BLS" wrote:

I have two different workbooks, a test book and a results book. I would like
to have a command button, that when clicked, opens the results workbook and
fill the users name and answers in the appropriate columns, say A1 through
G1. Then it saves the results workbook, closes it, and clears the contents of
the cells in the test workbook that contains the answers the user selected.
Then when someone else takes the test and does the same thing, their answers
are saved BELOW the first person in the results workbook, allowing me to use
the same test workbook and log everyone's results n the same workbook. I know
how to call open a new workbook, save and close it, and clear the contents,
but what I don't know is how to get the second or third or fourth users
answers to be entered in the row below the person before them. Hope this
makes sense and someone can help. Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default VB code to fill next available cell

do it this way:

LastRow = .Cells(.Rows.Count, "B").End(xlUp) + 1
LastRow.Select

:)
susan


On Nov 12, 1:06*pm, GLHEC-BLS
wrote:
That works great, but I don't understand the last part about adding 1. I
understand this is supose to tak eit to the row below the one with the last
entry, but I'm not sure where you mean to add the + 1 to the variable
LastRow. This is what I have right now.

Private Sub Worksheet_Activate()
Dim LastRow As Long

With Worksheets("Learning Style")
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Select

End With

End Sub



"Sheeloo" wrote:
The following code fragment will give you the last row used, in Col A, on
Data Sheet
in the variable LastRow... Add 1 to it and write to that row...
Dim LastRow As Long


With Worksheets("Data")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row


End With
MsgBox LastRow


"GLHEC-BLS" wrote:


I have two different workbooks, a test book and a results book. I would like
to have a command button, that when clicked, opens the results workbook and
fill the users name and answers in the appropriate columns, say A1 through
G1. Then it saves the results workbook, closes it, and clears the contents of
the cells in the test workbook that contains the answers the user selected.
Then when someone else takes the test and does the same thing, their answers
are saved BELOW the first person in the results workbook, allowing me to use
the same test workbook and log everyone's results n the same workbook.. I know
how to call open a new workbook, save and close it, and clear the contents,
but what I don't know is how to get the second or third or fourth users
answers to be entered in the row below the person before them. Hope this
makes sense and someone can help. Thanks!- Hide quoted text -


- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,805
Default VB code to fill next available cell

What I had meant was that LastRow will give you the last filled row. So if
you want to write to the next row you will have to add 1 to LastRow
variable...


"GLHEC-BLS" wrote:

That works great, but I don't understand the last part about adding 1. I
understand this is supose to tak eit to the row below the one with the last
entry, but I'm not sure where you mean to add the + 1 to the variable
LastRow. This is what I have right now.

Private Sub Worksheet_Activate()
Dim LastRow As Long

With Worksheets("Learning Style")
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Select

End With

End Sub

"Sheeloo" wrote:

The following code fragment will give you the last row used, in Col A, on
Data Sheet
in the variable LastRow... Add 1 to it and write to that row...
Dim LastRow As Long

With Worksheets("Data")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

End With
MsgBox LastRow

"GLHEC-BLS" wrote:

I have two different workbooks, a test book and a results book. I would like
to have a command button, that when clicked, opens the results workbook and
fill the users name and answers in the appropriate columns, say A1 through
G1. Then it saves the results workbook, closes it, and clears the contents of
the cells in the test workbook that contains the answers the user selected.
Then when someone else takes the test and does the same thing, their answers
are saved BELOW the first person in the results workbook, allowing me to use
the same test workbook and log everyone's results n the same workbook. I know
how to call open a new workbook, save and close it, and clear the contents,
but what I don't know is how to get the second or third or fourth users
answers to be entered in the row below the person before them. Hope this
makes sense and someone can help. Thanks!



Reply
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
remove fill in text from a cell from an unpopulated fill-in cell Deb[_3_] Excel Worksheet Functions 1 September 22nd 09 03:28 PM
Code to copy cell borders and fill color from one cell to another Chuck M Excel Programming 4 January 10th 08 12:34 PM
Fill cells with code based on content of preceeding cell? DekHog Excel Programming 1 June 8th 07 06:37 AM
VBA code to fill rest of cell with dashes (-) mikeburg[_97_] Excel Programming 2 August 18th 06 12:58 AM
Can I auto fill a cell in one worksheet by typing a code number Gomer Pyle Excel Worksheet Functions 1 August 27th 05 01:24 AM


All times are GMT +1. The time now is 07:07 PM.

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"