Friday, November 27, 2009

Re: [ExcelVBA] R1C1 Problem

 

The .Formula attribute is just a string. What you are doing is setting the
formula of one cell the same as the formula of another.

What you want is the effect that Excel will give you if you use copy/paste
to paste a formula down. Why not just copy/paste it from within your code.
That'll do the job.

Alternatively, R1C1 form will certainly work. But your FormulaR1C1 setting
is not R1C1 - it has F12 and G12 in it, which are not R1C1.

If you want to use FormulaR1C1, then it'd be worth chasing it up in a Google
search and looking at some examples there.

Regards, Dave S

----- Original Message -----
From: "ndrought" <ndrought@yahoo.com>
To: <ExcelVBA@yahoogroups.com>
Sent: Saturday, November 28, 2009 3:04 AM
Subject: [ExcelVBA] R1C1 Problem

>I am making a new sheet tool on my sheet to add rows and copy the formula
>from above. I can do most of it but cant get it to keep the relative
>position. I have found that i need to try R1C1 but i cant seem to get it to
>work with anything other than Sum formula.
>
> What i have in the cell i want to copy down is =F12*G12 and i will want it
> to become =F13*G13.
>
> I am selecting the cell first. However i am also using the variable p to
> decide what row and that figure is added to each next
>
> o = InputBox("How many Rows do you want to add?")
> For g = 1 To o
> p = Worksheets("Company Information").Cells(40, 13).Value
> Worksheets("Mileage").Cells(p, 3).Select
> Selection.EntireRow.Insert shift:=xlDown
> Cells(p, 8).Formula = Cells(p - 1, 8).Formula
> Cells(p, 8).Select
> ActiveCell.FormulaR1C1 = "= (F12[+1]*G12[+1])"
> Worksheets("Company Information").Cells(40, 13).Value =
> Worksheets("Company Information").Cells(40, 13).Value + 1
> Next
>
> Ideally i want it to be =F(p)*G(p) but i have no idea how to do that.
> Especially not with R1C1.
>
>
>
> ------------------------------------
>
> ----------------------------------
> Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go
> here: http://www.mousetrax.com/techtrax to enter the ezine, then search
> the ARCHIVES for EXCEL VBA.
>
> ----------------------------------
> Visit our ExcelVBA group home page for more info and support files:
> http://groups.yahoo.com/group/ExcelVBA
>
> ----------------------------------
> More free tutorials and resources available at:
> http://www.mousetrax.com
>
> ----------------------------------Yahoo! Groups Links
>
>
>

----------------------------------------------------------

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.426 / Virus Database: 270.14.83/2529 - Release Date: 11/26/09
19:42:00

__._,_.___
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

[ExcelVBA] Re: Add in - Menu deactivation | Need help

 

Manikandan,

This isn't very clear to me. You have an Addin file having two modules. One module activates (.Enable=True / .Visible=True), the CommandBar(s), the other the reverse. The deactivation module can be run if you include the "deactivation" code in a Sub named auto_close in the Addin file. When Excel is closed, the code in the auto_close sub will run. This is what is I interpret what you are doing when you "manually deactivating the Add-in from the excel file." (not really sure what this means).

Dave Gathmann

--- In ExcelVBA@yahoogroups.com, Raghavan Manikandan <geethanjali_mani@...> wrote:
>
> Dear Friends,
>  
> I have a separate module for activating & deactivating the Menu in the Excel file (using Add-ins), the macro will be executed based on the selection of the menu items. But I am not sure how can we execute the deactivation module when we manually deactivating the Add-in from the excel file.
>  
> could you anyone help me on the same?
>  
> Thanks & Regards
> Manikandan Raghavan
>  
>
>
>
>
> [Non-text portions of this message have been removed]
>

__._,_.___
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

RE: [ExcelVBA] R1C1 Problem

 

o = InputBox("How many Rows do you want to add?")
p = Worksheets("Company Information").Cells(40, 13).Value

With Worksheets("Mileage")

.Cells(p, 3).Resize(o).EntireRow.Insert shift:=xlDown
.Cells(p, 8).Resize(o).Formula = "=F12*G12"
End With



_____

From: ExcelVBA@yahoogroups.com [mailto:ExcelVBA@yahoogroups.com] On Behalf
Of ndrought
Sent: 27 November 2009 16:05
To: ExcelVBA@yahoogroups.com
Subject: [ExcelVBA] R1C1 Problem

I am making a new sheet tool on my sheet to add rows and copy the formula
from above. I can do most of it but cant get it to keep the relative
position. I have found that i need to try R1C1 but i cant seem to get it to
work with anything other than Sum formula.

What i have in the cell i want to copy down is =F12*G12 and i will want it
to become =F13*G13.

I am selecting the cell first. However i am also using the variable p to
decide what row and that figure is added to each next

o = InputBox("How many Rows do you want to add?")
For g = 1 To o
p = Worksheets("Company Information").Cells(40, 13).Value
Worksheets("Mileage").Cells(p, 3).Select
Selection.EntireRow.Insert shift:=xlDown
Cells(p, 8).Formula = Cells(p - 1, 8).Formula
Cells(p, 8).Select
ActiveCell.FormulaR1C1 = "= (F12[+1]*G12[+1])"
Worksheets("Company Information").Cells(40, 13).Value = Worksheets("Company
Information").Cells(40, 13).Value + 1
Next

Ideally i want it to be =F(p)*G(p) but i have no idea how to do that.
Especially not with R1C1.

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.426 / Virus Database: 270.14.83/2529 - Release Date: 11/26/09
19:42:00

[Non-text portions of this message have been removed]

__._,_.___
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

[ExcelVBA] R1C1 Problem

 

I am making a new sheet tool on my sheet to add rows and copy the formula from above. I can do most of it but cant get it to keep the relative position. I have found that i need to try R1C1 but i cant seem to get it to work with anything other than Sum formula.

What i have in the cell i want to copy down is =F12*G12 and i will want it to become =F13*G13.

I am selecting the cell first. However i am also using the variable p to decide what row and that figure is added to each next

o = InputBox("How many Rows do you want to add?")
For g = 1 To o
p = Worksheets("Company Information").Cells(40, 13).Value
Worksheets("Mileage").Cells(p, 3).Select
Selection.EntireRow.Insert shift:=xlDown
Cells(p, 8).Formula = Cells(p - 1, 8).Formula
Cells(p, 8).Select
ActiveCell.FormulaR1C1 = "= (F12[+1]*G12[+1])"
Worksheets("Company Information").Cells(40, 13).Value = Worksheets("Company Information").Cells(40, 13).Value + 1
Next

Ideally i want it to be =F(p)*G(p) but i have no idea how to do that. Especially not with R1C1.

__._,_.___
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

[ExcelVBA] Add in - Menu deactivation | Need help

 

Dear Friends,
 
I have a separate module for activating & deactivating the Menu in the Excel file (using Add-ins), the macro will be executed based on the selection of the menu items. But I am not sure how can we execute the deactivation module when we manually deactivating the Add-in from the excel file.
 
could you anyone help me on the same?
 
Thanks & Regards
Manikandan Raghavan
 

[Non-text portions of this message have been removed]

__._,_.___
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Thursday, November 26, 2009

RE: [ExcelVBA] Re: Put data to Web Page

I Googled a line of the code and found a site which told me what references
to set. One was named slightly differently from those listed on my computer
but the .dll file was shown so I browsed for it.

It really seems that the best approach is to try to see if someone has done
what you want to do (via Google) and then adapt it. Every software writer
writes their own .dlls and some even write object libraries which you can
easily use in VBA. Beyond that it is usually a question of trying to get
the intellisense to tell you what to do.

Regards

David Grugeon
Moderator - Excel VBA

Original message

> -----Original Message-----
> From: ExcelVBA@yahoogroups.com [mailto:ExcelVBA@yahoogroups.com] On Behalf
Of
> PatrickM
> Sent: Thursday, November 26, 2009 1:45 AM
> To: ExcelVBA@yahoogroups.com
> Subject: [ExcelVBA] Re: Put data to Web Page
>
> Hello,
> Please excuse my jumping in.
> David, you raise a good question for me: how did you know which references
to set?
> More generally, when I look at the Tools / References in the IDE, I see a
huge number of
> choices. How do I know what they all do? Is there a Help somewhere on
this?
> I feel like my ability with Excel VBA could expand if I just had a quick
feel for "I want to
> do X; I will need the reference Y and the objects A, B, and C."
> Thank you,
> Pat
>
> --- In ExcelVBA@yahoogroups.com, "David Grugeon" <yahoo@...> wrote:
> >
> > Hi Sujit
> >
> > I just put the code in a module (actually it was the sheet1 module) in a
new
> > workbook. I set the references
> >
> > Microsoft HTML Object library, and
> > Microsoft Internet controls.
> >
> > Ran the sub using F5 from the IDE and it just worked.
> >
> > I am using Windows XP, Excel 2007 SP2, and IE 8.
> >
> > I also get the error on
> >
> > oBrowser.timeout = 60
> >
> > which does not seem to matter.
> >
> > but no error on
> >
> > HTMLDoc.all.inputtext.Value = "ALBK"
> >
> > I doubt if this is helpful to you but hope you solve your problem.
> >
> > Best Regards
> > David Grugeon
> > Moderator ExcelVBA Group
> >
> > -----Original Message-----
> > From: ExcelVBA@yahoogroups.com [mailto:ExcelVBA@yahoogroups.com] On
Behalf
> > Of Sujit Talukder
> > Sent: Tuesday, 24 November 2009 3:55 PM
> > To: ExcelVBA@yahoogroups.com
> > Subject: RE: [ExcelVBA] Put data to Web Page
> >
> > Thanks David for the reply.
> >
> > You said it runs fine on your computer and putting the dates. Please
suggest
> > the way how you did it?
> >
> > When I removed the error handler code, It throws an error - Run time
error
> > 438. Object doesnot support this property or method. At this line:
> >
> > oBrowser.timeout = 60
> >
> > If I comment it out, then at this line:
> >
> > HTMLDoc.all.inputtext.Value = "ALBK"
> >
> >
> >
> > Which reference need I use?
> >
> > I am now using :
> >
> > Microsoft HTML object Library.
> >
> > Microsoft Internet controls
> >
> >
> >
> >
> >
> > _____
> >
> > From: ExcelVBA@yahoogroups.com [mailto:ExcelVBA@yahoogroups.com] On
Behalf
> > Of David Grugeon
> > Sent: 24 November 2009 02:39
> > To: ExcelVBA@yahoogroups.com
> > Subject: RE: [ExcelVBA] Put data to Web Page
> >
> >
> >
> >
> >
> > OK.. I found the references. It runs fine on my computer and puts the
dates
> > in. I suggest you try commenting out the error handling code and see if
it
> > is throwing an error.
> >
> > Best Regards
> > David Grugeon
> > Moderator ExcelVBA Group
> >
> > -----Original Message-----
> > From: ExcelVBA@yahoogroup <mailto:ExcelVBA%40yahoogroups.com> s.com
> > [mailto:ExcelVBA@yahoogroup <mailto:ExcelVBA%40yahoogroups.com> s.com]
On
> > Behalf
> > Of skt2114
> > Sent: Monday, 23 November 2009 8:18 PM
> > To: ExcelVBA@yahoogroup <mailto:ExcelVBA%40yahoogroups.com> s.com
> > Subject: [ExcelVBA] Put data to Web Page
> >
> > I am using the following code to open a web page and put value to web
page
> > controls.
> >
> > Dim HTMLDoc As HTMLDocument
> > Dim oBrowser As InternetExplorer
> > Sub Login_2_NSE()
> > Dim oHTML_Element As IHTMLElement
> > Dim sURL As String
> >
> > On Error GoTo Err_Clear
> > sURL = "http://www.nseindia
> > <http://www.nseindia.com/content/equities/eq_scriphistdata.htm>
> > .com/content/equities/eq_scriphistdata.htm"
> > Set oBrowser = New InternetExplorer
> > oBrowser.Silent = True
> > oBrowser.timeout = 60
> > oBrowser.navigate sURL
> > oBrowser.Visible = True
> >
> > Do
> > ' Wait till the Browser is loaded
> > Loop Until oBrowser.readyState = READYSTATE_COMPLETE
> >
> > Set HTMLDoc = oBrowser.document
> > HTMLDoc.all.inputtext.Value = "ALBK"
> > HTMLDoc.all.Series.Value = "EQ"
> > HTMLDoc.all.FromDate.Value = "01-01-1990"
> > HTMLDoc.all.ToDate.Value = "23-11-2009"
> > Err_Clear:
> > If Err <> 0 Then
> > Err.Clear
> > Resume Next
> > End If
> > End Sub
> >
> > The code is putting the values "ALBK" and "EQ" but not the FromDate and
> > Todate.
> >
> > Can someone please help me to sort out the problem so that the code will
> > insert Fromdate and toDate and then click the "Get Results" button on
the
> > web page.
> >
> > ------------------------------------
> >
> > ----------------------------------
> > Be sure to check out TechTrax Ezine for many, free Excel VBA articles!
Go
> > here: http://www.mousetra <http://www.mousetrax.com/techtrax>
x.com/techtrax
> > to enter the ezine, then search the
> > ARCHIVES for EXCEL VBA.
> >
> > ----------------------------------
> > Visit our ExcelVBA group home page for more info and support files:
> > http://groups. <http://groups.yahoo.com/group/ExcelVBA>
> > yahoo.com/group/ExcelVBA
> >
> > ----------------------------------
> > More free tutorials and resources available at:
> > http://www.mousetra <http://www.mousetrax.com> x.com
> >
> > ----------------------------------Yahoo! Groups Links
> >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
> > ------------------------------------
> >
> > ----------------------------------
> > Be sure to check out TechTrax Ezine for many, free Excel VBA articles!
Go
> > here: http://www.mousetrax.com/techtrax to enter the ezine, then search
the
> > ARCHIVES for EXCEL VBA.
> >
> > ----------------------------------
> > Visit our ExcelVBA group home page for more info and support files:
> > http://groups.yahoo.com/group/ExcelVBA
> >
> > ----------------------------------
> > More free tutorials and resources available at:
> > http://www.mousetrax.com
> >
> > ----------------------------------Yahoo! Groups Links
> >
>
>
>
>
> ------------------------------------
>
> ----------------------------------
> Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go
here:
> http://www.mousetrax.com/techtrax to enter the ezine, then search the
ARCHIVES for
> EXCEL VBA.
>
> ----------------------------------
> Visit our ExcelVBA group home page for more info and support files:
> http://groups.yahoo.com/group/ExcelVBA
>
> ----------------------------------
> More free tutorials and resources available at:
> http://www.mousetrax.com
>
> ----------------------------------Yahoo! Groups Links
>
>
>


------------------------------------

----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ExcelVBA/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/ExcelVBA/join
(Yahoo! ID required)

<*> To change settings via email:
ExcelVBA-digest@yahoogroups.com
ExcelVBA-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
ExcelVBA-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

RE: [ExcelVBA] Re: Check to see if Excel 2007 is already open and reference it using Excel 2003 VBA

 

Yep, unfortunately using that line of code doesn't always get the Excel
2007.

Anyways, thanks again for your help Dave... if I find a solution that works,
will let you know.

Cheers,

Tim

From: ExcelVBA@yahoogroups.com [mailto:ExcelVBA@yahoogroups.com] On Behalf
Of dmgathmann
Sent: Thursday, 26 November 2009 10:41 AM
To: ExcelVBA@yahoogroups.com
Subject: [ExcelVBA] Re: Check to see if Excel 2007 is already open and
reference it using Excel 2003 VBA

Tim,

I believe that your code should be:

Set xl12=GetObject(,"Excel.Application")

to get the already running app. My impression is that, if more than one
Excel instance is running at the same time, regardless of version, with this
function you always get the instance that was launched first, thus the need
for a handle.

I would point out that relying on the directory in which a file is stored
for information about the app is really merely 'a good guess'.

This is more or less where my help ends. Googling SendMessage seemed to
indicate that you can manipulate a lot of objects with it, but how to use it
and whether there are more appropriate methods, I don't know. I've avoided
API calls, and it seems that I'd need to do a lot of work before I was
comfortable using them.

Dave Gathmann

--- In ExcelVBA@yahoogroups.com <mailto:ExcelVBA%40yahoogroups.com> , "Tim"
<timothytal@...> wrote:
>
> Thanks very much for your suggestion Dave...
>
>
>
> I added the following line of code to determine the version:
>
> If InStr(process.CommandLine,"Office12")<>0 Then TheVersion = "12.0"
>
>
>
> Now that I've determined that Excel 2007 is open/running, is there any way
> to reference it as an application so I can control it from Excel 2003?
>
>
>
> I've tried...
>
>
>
> Dim xl12 As Object
>
> Set xl12 = GetObject("C:\Program Files\Microsoft Office
> 2007\Office12\EXCEL.EXE")
>
>
>
> But that just results in an error. If I know the handle (from using your
> code below) does this enable me to reference the Excel 2007 application
> somehow?
>
>
>
> Tim
>
>
>
> From: ExcelVBA@yahoogroups.com <mailto:ExcelVBA%40yahoogroups.com>
[mailto:ExcelVBA@yahoogroups.com <mailto:ExcelVBA%40yahoogroups.com> ] On
Behalf
> Of dmgathmann
> Sent: Wednesday, 25 November 2009 7:47 AM
> To: ExcelVBA@yahoogroups.com <mailto:ExcelVBA%40yahoogroups.com>
> Subject: [ExcelVBA] Re: Check to see if Excel 2007 is already open and
> reference it using Excel 2003 VBA
>
>
>
>
>
> Tim,
> This is only a partial solution. The first part gets you the handles to
any
> running Excel apps. I got this awhile back, and didn't record the author.
> You may be able to get the version using the SendMessage API function, but
I
> don't know what the params need to be set at (perhaps others viewing this
> forum would).
>
> Public Sub showProcesses()
> Dim W As Object
> Dim sQuery As String
> Dim processes As Object
> Dim process As Object
> Dim TheHandle As Integer
> Dim TheName As String
> Dim TheVersion As String
> Dim TheMsg As String
>
> Set W = GetObject("winmgmts:")
> sQuery = "SELECT * FROM win32_process"
> Set processes = W.execquery(sQuery)
> TheVersion = Application.Version
> For Each process In processes
> If InStr(process.Name, "EXCEL") <> 0 Then
> TheName = process.Name
> TheHandle = process.Handle
> 'TheVersion = SendMessage(TheHandle, Msg, WParam, lParam)
> End If
> Next
>
> Set W = Nothing
> Set processes = Nothing
> Set process = Nothing
> End Sub
>
> 'function to get the version
> Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" _
> (ByVal hwnd As Long, _
> ByVal wMsg As Long, _
> ByVal wParam As Long, _
> ByVal lParam As Any) As Long
>
> If you've already found your answer, I'd be interested in knowing what it
> is.
>
> Dave Gathmann
>
> --- In ExcelVBA@yahoogroups.com <mailto:ExcelVBA%40yahoogroups.com>
<mailto:ExcelVBA%40yahoogroups.com> , "Tim"
> <timothytal@> wrote:
> >
> > Hi,
> >
> >
> >
> > Using VBA in a workbook open in Excel 2003, is there any way to find out
> whether or not Excel 2007 is open also? For example, a user might have one
> or more instances of Excel 2003 open on their desktop, as well as one or
> more instances of Excel 2007. Can I use VBA in 2003 to find an instance of
> Excel 2007 and reference it as an application?
> >
> >
> >
> > Tim
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.425 / Virus Database: 270.14.79/2522 - Release Date: 11/23/09
> 19:45:00
>
>
>
> [Non-text portions of this message have been removed]
>

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.425 / Virus Database: 270.14.81/2524 - Release Date: 11/24/09
19:37:00

[Non-text portions of this message have been removed]

__._,_.___
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___