#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Loop question

I am trying to create a Do Until loop that will display a form that will
display until a checkbox is checked. The answer to the question on the form
needs to be written to the spreadsheet in the cell below the previous answer.
I'm fairly new to this, but I'm guessing I need to use Offset. I've never
done that before. Anyone have any suggestions and/or hints? Thank you!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default Loop question

Once the checkbox is checked and you presumably have a valid answer, this
kind of logic in your code should work. Presumes that the answer is held in
variable myAnswer (could come from text entry on the form itself), and the
column to store the answers in is column B.

ActiveSheet.Range("B" & Rows.Count).End(xlUp).Offset(1,0) = myAnswer

The ActiveSheet.Range("B" & Rows.Count).End(xlUp) portion locates the last
used cell in column B by looking from the bottom of the sheet toward to the
top. As you'd guessed, the .Offset(1,0) gives the location just below the
last used cell in the column, or the first blank available in that column, if
you look at it that way.

If you're using Excel 2007, use Rows.CountLarge instead of Rows.Count

"aelewis" wrote:

I am trying to create a Do Until loop that will display a form that will
display until a checkbox is checked. The answer to the question on the form
needs to be written to the spreadsheet in the cell below the previous answer.
I'm fairly new to this, but I'm guessing I need to use Offset. I've never
done that before. Anyone have any suggestions and/or hints? Thank you!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Loop question

Thank you! I will try that.

"JLatham" wrote:

Once the checkbox is checked and you presumably have a valid answer, this
kind of logic in your code should work. Presumes that the answer is held in
variable myAnswer (could come from text entry on the form itself), and the
column to store the answers in is column B.

ActiveSheet.Range("B" & Rows.Count).End(xlUp).Offset(1,0) = myAnswer

The ActiveSheet.Range("B" & Rows.Count).End(xlUp) portion locates the last
used cell in column B by looking from the bottom of the sheet toward to the
top. As you'd guessed, the .Offset(1,0) gives the location just below the
last used cell in the column, or the first blank available in that column, if
you look at it that way.

If you're using Excel 2007, use Rows.CountLarge instead of Rows.Count

"aelewis" wrote:

I am trying to create a Do Until loop that will display a form that will
display until a checkbox is checked. The answer to the question on the form
needs to be written to the spreadsheet in the cell below the previous answer.
I'm fairly new to this, but I'm guessing I need to use Offset. I've never
done that before. Anyone have any suggestions and/or hints? Thank you!

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
Loop question N.F[_2_] Excel Discussion (Misc queries) 0 July 12th 07 08:02 PM
Loop QUESTION to end of data range... mniccole Excel Worksheet Functions 2 December 4th 06 09:25 PM
Loop QUESTION to end of data range... mniccole Excel Worksheet Functions 2 December 4th 06 05:19 PM
Loop QUESTION to end of data range... mniccole Excel Worksheet Functions 0 December 4th 06 03:59 PM
Password Loop question. Andy Tallent Excel Discussion (Misc queries) 1 April 8th 05 01:16 PM


All times are GMT +1. The time now is 04:08 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"