Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default update a new row everytime I click a button

Hi All,

How can I loop through excel rows by clicking a button. I want to populate a
new row in excel every time I click a button.

For eg: I Click a button that I created on access form, on clicking this
button will open a dialog window where we can select the excel file(template)
then we launch excel file then --Populate it -- Save it with different
name..

I want to keep this excel file open and keep on updating the sheet with data
in the next empty row with records from access by clicking that button...
Is there a way to loop it like this? and keep updating the sheet with data
in next row?
Here is the part of code for looping through new rows. But it doesnt work as
I want it to.


Dim r as long

Set wst = Worksheets("sheet1")

With wst
..Range("A1").Value = Me.City.Value

End With

r = r + 1

FName = "C:\My Documents\" _
& "Address" & ".xls"

wst.SaveAs FileName:=FName

Hope I made it clear.

Thanks in Advance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default update a new row everytime I click a button

I do logging like this a lot. The way I do it is as follows.

1. In the workbook, on the worksheet where the info will be gathering, I
use a worksheet formula "=counta(A3:A9999)" in cell A1.
2. Row 2 is used for my column headings.
3. Row 3 through Row 9999 is used to collect the info.
4. In the code, I query the value of cell A1(which is the number of
records) and store it as MyRecords.
5. Then I generate a NextRow variable by the formula "NextRow=MyRecords+3".
"3" is the starting row when there are no records.
6. I append the new data like this.
Worksheet("Sheet1").Range("A"+Cstr(NextRow)).Value =the new column A
data
Worksheet("Sheet1").Range("B"+Cstr(NextRow)).Value =the new column B
data
Worksheet("Sheet1").Range("C"+Cstr(NextRow)).Value =the new column C
data

Cell A1 updates and the new data is always put on the next row.

Caution: do not do this....
Worksheet("Sheet1").Range("A"+Cstr(
Worksheet("Sheet1").Range("A1").Value+3)).Value=th e new column A data
Worksheet("Sheet1").Range("B"+Cstr(
Worksheet("Sheet1").Range("A1").Value+3)).Value=th e new column B data
Worksheet("Sheet1").Range("C"+Cstr(
Worksheet("Sheet1").Range("A1").Value+3)).Value=th e new column C data
This will start by putting data in the first cell correctly, but the value
of cell A1 updates right away and the data for columns B and C will be
shifted down one row.


Dennis



"sam" wrote in message
...
Hi All,

How can I loop through excel rows by clicking a button. I want to populate
a
new row in excel every time I click a button.

For eg: I Click a button that I created on access form, on clicking this
button will open a dialog window where we can select the excel
file(template)
then we launch excel file then --Populate it -- Save it with different
name..

I want to keep this excel file open and keep on updating the sheet with
data
in the next empty row with records from access by clicking that button...
Is there a way to loop it like this? and keep updating the sheet with data
in next row?
Here is the part of code for looping through new rows. But it doesnt work
as
I want it to.


Dim r as long

Set wst = Worksheets("sheet1")

With wst
.Range("A1").Value = Me.City.Value

End With

r = r + 1

FName = "C:\My Documents\" _
& "Address" & ".xls"

wst.SaveAs FileName:=FName

Hope I made it clear.

Thanks in Advance

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
after click a button(commandbutton), getting the button name x taol Excel Programming 3 February 15th 08 09:35 PM
how to get an equation to update everytime a column is inserted? IsaBeL Excel Discussion (Misc queries) 3 October 14th 06 04:36 AM
Excel - need an serial # to update everytime sheet is printed. C. Excel Worksheet Functions 0 March 27th 06 09:21 PM
Create floating button based on button click in menu ExcelMonkey Excel Programming 2 October 12th 05 06:43 PM
sum doesn't update total without double-click of cell David E. Gross Excel Discussion (Misc queries) 1 February 5th 05 12:44 AM


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