Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default 'splain the code please :)

Hello, thank you for helping in advance..
i have a couple of macros that was i was working on and
was helped ( alot).. i am currently reading a excel step
by step book by reed jacobson and i am learning the term
adn properties as i go along here. Will anyone be willing
to decipher and explain each statement in "idiot" terms
so i can see how it actually worked and understand it? i
find it fascinating to do macros. I would be thrilled if
anyone can break these down.
again thanks you for helping. mike

Sub copy_to_sheet()
copy_to = "Month" & Range("month_val").Value
last_used = Sheets(copy_to).Cells.SpecialCells _
(xlCellTypeLastCell).Address
copy_to_address = Rows(Sheets(copy_to).Range _
(last_used).Row + 2).Columns(1).Address
If copy_to_address = "$A$3" Then copy_to_address = "$A$1"
Sheets("form").Range("form_data").Copy Destination:=Sheets
(copy_to).Range(copy_to_address)


End Sub


and...

Private Sub Worksheet_Change(ByVal Target As Range)

this_month = 1
dd = Range("start_date").Value
Do While dd < Range("ref_date").Value
dd = 1 + dd
If Day(dd) = 25 Then this_month = 1 + this_month
Loop
Range("month_val").Value = this_month
End Sub

**what did the argument in paratheses mean? "(ByVal
Target As Range)" and "this_month = 1 ..What is
this "statement" telling Excel?


thanks!!!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default 'splain the code please :)

(by Value Target As Range) is a parameter passed to your procedure as part
of the Worksheet Change event.

'this_month' is a variable used by your procedures, its name is decriptive
only as defined by the author of the code.


"mike" wrote in message
...
Hello, thank you for helping in advance..
i have a couple of macros that was i was working on and
was helped ( alot).. i am currently reading a excel step
by step book by reed jacobson and i am learning the term
adn properties as i go along here. Will anyone be willing
to decipher and explain each statement in "idiot" terms
so i can see how it actually worked and understand it? i
find it fascinating to do macros. I would be thrilled if
anyone can break these down.
again thanks you for helping. mike

Sub copy_to_sheet()
copy_to = "Month" & Range("month_val").Value
last_used = Sheets(copy_to).Cells.SpecialCells _
(xlCellTypeLastCell).Address
copy_to_address = Rows(Sheets(copy_to).Range _
(last_used).Row + 2).Columns(1).Address
If copy_to_address = "$A$3" Then copy_to_address = "$A$1"
Sheets("form").Range("form_data").Copy Destination:=Sheets
(copy_to).Range(copy_to_address)


End Sub


and...

Private Sub Worksheet_Change(ByVal Target As Range)

this_month = 1
dd = Range("start_date").Value
Do While dd < Range("ref_date").Value
dd = 1 + dd
If Day(dd) = 25 Then this_month = 1 + this_month
Loop
Range("month_val").Value = this_month
End Sub

**what did the argument in paratheses mean? "(ByVal
Target As Range)" and "this_month = 1 ..What is
this "statement" telling Excel?


thanks!!!





----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 'splain the code please :)

Sub copy_to_sheet()
' construct a string made up of "Month" and concatenate the value in a cell
' named "month_val". the string is held in a variable named copy_to
' this string will represent the name of a sheet
copy_to = "Month" & Range("month_val").Value

' get the address of the last used cell on the worksheets
' place it in a variable last_used. Use the specialcells method
' to get this. The argument to tell specialcells to provide this
' information is the defined constants xlCellTypeLastCell
' special cells can provide other information if provided with
' a different argument. Use of this command is equivalent to
' manually doing Edit=Goto=Special and choosing
' last cell
' in code, it returns a cell reference, and we put address
' on the end to get the address of the referenced cell.
' we find this information for the sheet whose name is
' held in the copy_to variable.
last_used = Sheets(copy_to).Cells.SpecialCells _
(xlCellTypeLastCell).Address

'Now build a string that will hold the address we want to
' copy to. We use our copy_to variable determine the
' sheet to copy to. We will use the lastused cell in that
' and go down 2 additional rows, then over to the first column
' so our address would be something like $A$29
copy_to_address = Rows(Sheets(copy_to).Range _
(last_used).Row + 2).Columns(1).Address

' if the address is $A$3, then this means the sheet is empty
' so we want to copy to cell $A$1 instead
If copy_to_address = "$A$3" Then copy_to_address = "$A$1"

'Now we do the copy using the information we have gathered.
'We copy the information found in the Sheet named FORM at
'the range location defined by "form_data" (a defined name)
'and copy to the cell we previously identified.
Sheets("form").Range("form_data").Copy Destination:=Sheets
(copy_to).Range(copy_to_address)


End Sub

--
Regards,
Tom Ogilvy


"mike" wrote in message
...
Hello, thank you for helping in advance..
i have a couple of macros that was i was working on and
was helped ( alot).. i am currently reading a excel step
by step book by reed jacobson and i am learning the term
adn properties as i go along here. Will anyone be willing
to decipher and explain each statement in "idiot" terms
so i can see how it actually worked and understand it? i
find it fascinating to do macros. I would be thrilled if
anyone can break these down.
again thanks you for helping. mike

Sub copy_to_sheet()
copy_to = "Month" & Range("month_val").Value
last_used = Sheets(copy_to).Cells.SpecialCells _
(xlCellTypeLastCell).Address
copy_to_address = Rows(Sheets(copy_to).Range _
(last_used).Row + 2).Columns(1).Address
If copy_to_address = "$A$3" Then copy_to_address = "$A$1"
Sheets("form").Range("form_data").Copy Destination:=Sheets
(copy_to).Range(copy_to_address)


End Sub


and...

Private Sub Worksheet_Change(ByVal Target As Range)

this_month = 1
dd = Range("start_date").Value
Do While dd < Range("ref_date").Value
dd = 1 + dd
If Day(dd) = 25 Then this_month = 1 + this_month
Loop
Range("month_val").Value = this_month
End Sub

**what did the argument in paratheses mean? "(ByVal
Target As Range)" and "this_month = 1 ..What is
this "statement" telling Excel?


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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
VBA code delete code but ask for password and unlock VBA protection WashoeJeff Excel Programming 0 January 27th 04 07:07 AM
Help 'splain unusual behavior in simple procedure tod Excel Programming 0 January 13th 04 11:13 PM


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