PC Review


Reply
Thread Tools Rate Thread

Button to increase cell value and print document

 
 
Fludium
Guest
Posts: n/a
 
      4th Dec 2008
This is probably very easy but i dont know to much about macros yet.

Example
I have a invoice ref # 001 (existing document)

I want to press a button labeled "print" (user action)

The macro adds +1 to existing invoice ref# cell. Copy the value of cell "X"
, "Y" and "Z" and invoice ref# cell to spread sheet #2 (creating a database)

Prints active worksheet.

Saves the document

Now I have a new invoice ref #002 and the 3 cell values are stored together
in the database on spread sheet #2.

This way, next time i'm invoicing, my database gets updated and i'll have a
refrence number to all my invoices for history puposes.

Thanks.
 
Reply With Quote
 
 
 
 
Gary Keramidas
Guest
Posts: n/a
 
      4th Dec 2008
if you're in the us or uk, why don't you just download microsoft's free
accounting program?
http://office.microsoft.com/en-us/ac...729681033.aspx

direct download
http://www.ideawins.com/downloads1.aspx

--


Gary

"Fludium" <(E-Mail Removed)> wrote in message
news:F0CCA127-659C-47DD-8722-(E-Mail Removed)...
> This is probably very easy but i dont know to much about macros yet.
>
> Example
> I have a invoice ref # 001 (existing document)
>
> I want to press a button labeled "print" (user action)
>
> The macro adds +1 to existing invoice ref# cell. Copy the value of cell "X"
> , "Y" and "Z" and invoice ref# cell to spread sheet #2 (creating a database)
>
> Prints active worksheet.
>
> Saves the document
>
> Now I have a new invoice ref #002 and the 3 cell values are stored together
> in the database on spread sheet #2.
>
> This way, next time i'm invoicing, my database gets updated and i'll have a
> refrence number to all my invoices for history puposes.
>
> Thanks.



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      4th Dec 2008
I added a button from the Forms toolbar (not the control toolbox toolbar) to the
worksheet with the data. Then I assigned this macro to that button.

Option Explicit
Sub testme()
Dim InvCell As Range
Dim myAddr As Variant
Dim DestCell As Range
Dim iCtr As Long
Dim aCtr As Long

Set InvCell = ActiveSheet.Range("A1")
myAddr = Array("a9", "b12", "c3")

With Worksheets("Log")
Set DestCell = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

If IsNumeric(InvCell.Value) = False Then
MsgBox "Please fix: " & InvCell.Address(0, 0)
Exit Sub
End If

With InvCell
.Value = .Value + 1
End With

With DestCell
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
.Value = Now
.Offset(0, 1).Value = Application.UserName
.Offset(0, 2).Value = InvCell.Value
iCtr = 0
For aCtr = LBound(myAddr) To UBound(myAddr)
.Offset(0, iCtr + 3).Value = ActiveSheet.Range(myAddr(aCtr)).Value
iCtr = iCtr + 1
Next aCtr
End With

ActiveWorkbook.Save
ActiveSheet.PrintOut preview:=True 'save some paper while testing

End Sub

Fludium wrote:
>
> This is probably very easy but i dont know to much about macros yet.
>
> Example
> I have a invoice ref # 001 (existing document)
>
> I want to press a button labeled "print" (user action)
>
> The macro adds +1 to existing invoice ref# cell. Copy the value of cell "X"
> , "Y" and "Z" and invoice ref# cell to spread sheet #2 (creating a database)
>
> Prints active worksheet.
>
> Saves the document
>
> Now I have a new invoice ref #002 and the 3 cell values are stored together
> in the database on spread sheet #2.
>
> This way, next time i'm invoicing, my database gets updated and i'll have a
> refrence number to all my invoices for history puposes.
>
> Thanks.


--

Dave Peterson
 
Reply With Quote
 
Fludium
Guest
Posts: n/a
 
      5th Dec 2008
After a little tinkering with it, i got it to work. Great stuff!

Thank you very much!

"Dave Peterson" wrote:

> I added a button from the Forms toolbar (not the control toolbox toolbar) to the
> worksheet with the data. Then I assigned this macro to that button.
>
> Option Explicit
> Sub testme()
> Dim InvCell As Range
> Dim myAddr As Variant
> Dim DestCell As Range
> Dim iCtr As Long
> Dim aCtr As Long
>
> Set InvCell = ActiveSheet.Range("A1")
> myAddr = Array("a9", "b12", "c3")
>
> With Worksheets("Log")
> Set DestCell = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
> End With
>
> If IsNumeric(InvCell.Value) = False Then
> MsgBox "Please fix: " & InvCell.Address(0, 0)
> Exit Sub
> End If
>
> With InvCell
> .Value = .Value + 1
> End With
>
> With DestCell
> .NumberFormat = "mm/dd/yyyy hh:mm:ss"
> .Value = Now
> .Offset(0, 1).Value = Application.UserName
> .Offset(0, 2).Value = InvCell.Value
> iCtr = 0
> For aCtr = LBound(myAddr) To UBound(myAddr)
> .Offset(0, iCtr + 3).Value = ActiveSheet.Range(myAddr(aCtr)).Value
> iCtr = iCtr + 1
> Next aCtr
> End With
>
> ActiveWorkbook.Save
> ActiveSheet.PrintOut preview:=True 'save some paper while testing
>
> End Sub
>
> Fludium wrote:
> >
> > This is probably very easy but i dont know to much about macros yet.
> >
> > Example
> > I have a invoice ref # 001 (existing document)
> >
> > I want to press a button labeled "print" (user action)
> >
> > The macro adds +1 to existing invoice ref# cell. Copy the value of cell "X"
> > , "Y" and "Z" and invoice ref# cell to spread sheet #2 (creating a database)
> >
> > Prints active worksheet.
> >
> > Saves the document
> >
> > Now I have a new invoice ref #002 and the 3 cell values are stored together
> > in the database on spread sheet #2.
> >
> > This way, next time i'm invoicing, my database gets updated and i'll have a
> > refrence number to all my invoices for history puposes.
> >
> > Thanks.

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Fludium
Guest
Posts: n/a
 
      5th Dec 2008
Good idea, but a little to much for what i'm using it for...
Thanks anyway

"Gary Keramidas" wrote:

> if you're in the us or uk, why don't you just download microsoft's free
> accounting program?
> http://office.microsoft.com/en-us/ac...729681033.aspx
>
> direct download
> http://www.ideawins.com/downloads1.aspx
>
> --
>
>
> Gary
>
> "Fludium" <(E-Mail Removed)> wrote in message
> news:F0CCA127-659C-47DD-8722-(E-Mail Removed)...
> > This is probably very easy but i dont know to much about macros yet.
> >
> > Example
> > I have a invoice ref # 001 (existing document)
> >
> > I want to press a button labeled "print" (user action)
> >
> > The macro adds +1 to existing invoice ref# cell. Copy the value of cell "X"
> > , "Y" and "Z" and invoice ref# cell to spread sheet #2 (creating a database)
> >
> > Prints active worksheet.
> >
> > Saves the document
> >
> > Now I have a new invoice ref #002 and the 3 cell values are stored together
> > in the database on spread sheet #2.
> >
> > This way, next time i'm invoicing, my database gets updated and i'll have a
> > refrence number to all my invoices for history puposes.
> >
> > Thanks.

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Create Macro to Increase Cell Value to one and Print Worksheet mdms515@alltel.net Microsoft Excel Worksheet Functions 4 24th Jul 2008 08:48 PM
Number in cell increase with increase in font size. =?Utf-8?B?VmFsdWUgaW5jcmVhc2VzIHdpdGggaW5jcmVhc2Ug Microsoft Excel Misc 2 9th Aug 2007 01:58 PM
In excel how do I increase a number in a cell by 1 after I print? =?Utf-8?B?bWp0YXhwcm8=?= Microsoft Excel New Users 4 26th Jul 2007 11:36 PM
excel how to put a print button in the document =?Utf-8?B?bmljayBs?= Microsoft Excel Worksheet Functions 1 29th Mar 2007 05:18 PM
Macro to increase cell value by 1 each time button clicked fozzer Microsoft Excel Programming 2 29th Apr 2004 01:58 PM


Features
 

Advertising
 

Newsgroups
 


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