A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Links and Linking
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Populating Rows Below



 
 
Thread Tools Display Modes
  #1  
Old February 26th, 2008, 09:50 AM
gusdafa gusdafa is offline
Member
 
First recorded activity by OfficeFrustration: Feb 2008
Posts: 4
Default Populating Rows Below

Hi there, I hope this is the right section for this.

Got excellent answers on my first query here (thanks again)and it gave me an idea of how to further develop my spreadsheet.

Basically, I have a drop down list of names where once a name is selected, the time and date is populated. What I want to do now is to "push" this entry down the next row while freeing up the original top row for a new selection and updates. I would like to do this so that entries are in a descending order with the selection row left blank up top.

I've searched google for a remedy and came up with nothing.

Thanks for your time and effort in helping me.
  #2  
Old February 26th, 2008, 03:36 PM posted to microsoft.public.excel.links
Gary''s Student
external usenet poster
 
Posts: 7,584
Default Populating Rows Below

This assumes that the name is in A1 and the date/time are in B1. Run this
macro:

Sub push_down()
Set r1 = Range("A1:B1")
Set r2 = Range("A2:B2")
r1.Copy r2
r1.ClearContents
End Sub

The macro clears A1:B1, but leaves the pull-down in place for the next entry.
--
Gary''s Student - gsnu2007d


"gusdafa" wrote:


Hi there, I hope this is the right section for this.

Got excellent answers on my first query here (thanks again)and it gave
me an idea of how to further develop my spreadsheet.

Basically, I have a drop down list of names where once a name is
selected, the time and date is populated. What I want to do now is to
"push" this entry down the next row while freeing up the original top
row for a new selection and updates. I would like to do this so that
entries are in a descending order with the selection row left blank up
top.

I've searched google for a remedy and came up with nothing.

Thanks for your time and effort in helping me.




--
gusdafa

  #3  
Old February 26th, 2008, 08:43 PM
gusdafa gusdafa is offline
Member
 
First recorded activity by OfficeFrustration: Feb 2008
Posts: 4
Default

Quote:
Originally Posted by Gary''s Student View Post
This assumes that the name is in A1 and the date/time are in B1. Run this
macro:

Sub push_down()
Set r1 = Range("A1:B1")
Set r2 = Range("A2:B2")
r1.Copy r2
r1.ClearContents
End Sub

The macro clears A1:B1, but leaves the pull-down in place for the next entry.
--
Gary''s Student - gsnu2007d
Thanks for that, it worked.

Can you give some pointers with storing the previous copy on the rows below it (A3:B3) instead of it being overwritten? That plus the macro to autorun with each selection (at the moment I have to manually run the macro after a selection), and finally, a better handle on ClearContents as it not only clears out the cell content but also the formulas? I'm sorry if it sounds like I'm asking for the moon. I'll be doing some research on those queries but appreciate any help.

Thanks.
  #4  
Old February 27th, 2008, 01:12 AM posted to microsoft.public.excel.links
Gary''s Student
external usenet poster
 
Posts: 7,584
Default Populating Rows Below

This is more automatic. It is a worksheet event macro. It waits for you to
change cell A1. Once you change cell A1, a copy of the entire first row is
"pushed down". You can now update the values in the first row and when you
update A1, the new row will also be "pushed down"


Because it is worksheet code, it is very easy to install and automatic to use:

1. right-click the tab name near the bottom of the Excel window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you have any concerns, first try it on a trial worksheet.

If you save the workbook, the macro will be saved with it.


To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm




--
Gary''s Student - gsnu2007d


"gusdafa" wrote:


Gary''s Student;2644827 Wrote:
This assumes that the name is in A1 and the date/time are in B1. Run
this
macro:

Sub push_down()
Set r1 = Range("A1:B1")
Set r2 = Range("A2:B2")
r1.Copy r2
r1.ClearContents
End Sub

The macro clears A1:B1, but leaves the pull-down in place for the next
entry.
--
Gary''s Student - gsnu2007d

Thanks for that, it worked.

Can you give some pointers with storing the previous copy on the rows
below it (A3:B3) instead of it being overwritten? That plus the macro
to autorun with each selection (at the moment I have to manually run
the macro after a selection), and finally, a better handle on
ClearContents as it not only clears out the cell content but also the
formulas? I'm sorry if it sounds like I'm asking for the moon. I'll be
doing some research on those queries but appreciate any help.

Thanks.




--
gusdafa

  #5  
Old February 27th, 2008, 01:15 AM posted to microsoft.public.excel.links
Gary''s Student
external usenet poster
 
Posts: 7,584
Default Populating Rows Below

Here is the event code:

Private Sub Worksheet_Change(ByVal Target As Range)
Set r = Range("A1")
If Intersect(Target, r) Is Nothing Then Exit Sub
Application.EnableEvents = False
Rows("1:1").Select
Selection.Insert Shift:=xlDown
Rows("2:2").Select
Selection.Copy
Range("A1").Select
ActiveSheet.Paste
Application.EnableEvents = True
End Sub
--
Gary''s Student - gsnu2007d


"gusdafa" wrote:


Gary''s Student;2644827 Wrote:
This assumes that the name is in A1 and the date/time are in B1. Run
this
macro:

Sub push_down()
Set r1 = Range("A1:B1")
Set r2 = Range("A2:B2")
r1.Copy r2
r1.ClearContents
End Sub

The macro clears A1:B1, but leaves the pull-down in place for the next
entry.
--
Gary''s Student - gsnu2007d

Thanks for that, it worked.

Can you give some pointers with storing the previous copy on the rows
below it (A3:B3) instead of it being overwritten? That plus the macro
to autorun with each selection (at the moment I have to manually run
the macro after a selection), and finally, a better handle on
ClearContents as it not only clears out the cell content but also the
formulas? I'm sorry if it sounds like I'm asking for the moon. I'll be
doing some research on those queries but appreciate any help.

Thanks.




--
gusdafa

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


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


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.