changing vba cell reference

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,077
hello all,

I have been using VBA to send emails out to a set email address and corresponding password, however I need to reference a cell so that it can be changed as needed. I'm hoping I just made a little error...

This is the original:
Code:
  sTo = Right(sTo, Len(sTo) - 1)        Gmail "email@gmail.com", "password", "" _
        , "o> " _
        & vbNewLine & Sheets("Print").Range("D1")

Here is what I tried to do:
Code:
  sTo = Right(sTo, Len(sTo) - 1)        Gmail "Sheets("Home").Range("P16")", "Sheets("Home").Range("P18")", "" _
        , "o> " _
        & vbNewLine & Sheets("Print").Range("D1") _
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
hello all,

I have been using VBA to send emails out to a set email address and corresponding password, however I need to reference a cell so that it can be changed as needed. I'm hoping I just made a little error...

This is the original:
Code:
  sTo = Right(sTo, Len(sTo) - 1)        Gmail "email@gmail.com", "password", "" _
        , "o> " _
        & vbNewLine & Sheets("Print").Range("D1")

Here is what I tried to do:
Code:
  sTo = Right(sTo, Len(sTo) - 1)        Gmail "Sheets("Home").Range("P16")", "Sheets("Home").Range("P18")", "" _
        , "o> " _
        & vbNewLine & Sheets("Print").Range("D1") _
I am not 100% certain, but I would assume the bottom code would be changed to this:

Code:
  sTo = Right(sTo, Len(sTo) - 1)        [COLOR=#ff0000][B]Gmail Sheets("Home").Range("P16"), Sheets("Home").Range("P18")[/B][/COLOR], "" _
        , "o> " _
        & vbNewLine & Sheets("Print").Range("D1") _
I think wrapping those parts in quotation marks would have made them a fixed string rather than a reference to a cell value.
 
Upvote 0
Upvote 0

Forum statistics

Threads
1,215,585
Messages
6,125,679
Members
449,248
Latest member
wayneho98

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top