Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2007

Tip: Looking for answers? Try searching our database.

Easy Syntax Question - refer to current row & column to pull a val

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lisab - 17 Sep 2007 19:00 GMT
Although I am skilled at VB, I am still new to programming with Excel and am
having a problem figuring out the proper syntax for refering to a cell and
getting it's value to use in code.

1. I have a workbook with multiple worksheets.
2. The first worksheet is a list -> name, Email Address, and worksheet Name
3. each row has a command button that will run a macro to send that person
an email with the proper worksheet as an attachment. (code runs great - I got
it from here http://www.rondebruin.nl/mail/folder1/mail2.htm)

4. I want to customize this code by changing the hardcoding of the worksheet
name and email address

5. I need the syntax for referring to the current row (the row the command
button is being pressed from) and pulling the value from cell C (email
address)

I added the following dim statements:
   Dim EmailAddress As String
   Dim MailSheetName As String

and added the following statements:  (tested and works fine)

EmailAddress = Sheets("EmailList").Range("C1").Value
MailSheetName = Sheets("EmailList").Range("D1").value

I would like to replace .Range("C1"). with the proper syntax to refer to the
current row column C.   So if the command button in row 5 is pushed, the
values from C5 and D5 will be placed in the EmailAddress and MailSheetName.
Tim Zych - 17 Sep 2007 19:03 GMT
EmailAddress = Sheets("EmailList").Cells(ActiveCell.Row, "C").Value
or
EmailAddress = Sheets("EmailList").Cells(ActiveCell.Row, 3).Value

> Although I am skilled at VB, I am still new to programming with Excel and
> am
[quoted text clipped - 31 lines]
> values from C5 and D5 will be placed in the EmailAddress and
> MailSheetName.
Ron de Bruin - 17 Sep 2007 19:09 GMT
For the OP

See also the templates
http://www.rondebruin.nl/mail/templates.htm

Signature

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm

> EmailAddress = Sheets("EmailList").Cells(ActiveCell.Row, "C").Value
> or
[quoted text clipped - 35 lines]
>> values from C5 and D5 will be placed in the EmailAddress and
>> MailSheetName.
Lisab - 17 Sep 2007 20:12 GMT
Perfect!   Thank you both for your help.

> For the OP
>
[quoted text clipped - 40 lines]
> >> values from C5 and D5 will be placed in the EmailAddress and
> >> MailSheetName.
Lisab - 17 Sep 2007 20:14 GMT
Ron,

Thank you, I just happen to have three people on my list that would receive
the whole workbook and the link to your code is exactly what I need!

Thanks again.

> For the OP
>
[quoted text clipped - 40 lines]
> >> values from C5 and D5 will be placed in the EmailAddress and
> >> MailSheetName.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.