ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Copy Status bar macro (https://www.excelbanter.com/excel-discussion-misc-queries/121186-copy-status-bar-macro.html)

Bongard

Copy Status bar macro
 
I originally wanted to write a macro that would copy the value in the
status bar (sum of your selection or whatever function you have chosen)
but since I only use the sum function I thought it would be easier to
just use the sum fucntion of selection and copy it to the clipboard. I
found this macro and avice from an earlier post.


Sub Macro1()

'' Keyboard Shortcut: Ctrl+Shift+S

Dim MyData As DataObject
Set MyData = New DataObject

MyData.SetText
WorksheetFunction.Sum (Selection.SpecialCells(xlCellTypeVisible))
MyData.PutInClipboard

End Sub

In order to run since MyData is earlybind, you must go to tools
reference in
the VBA editor and select Microsoft Forms 2.0 Object Library. Or you
can
change to late bind (i.e. use CreateObject)


That being said, when I try to run the macro it gives me the error
Compile Error --- User-Defined type not defined.

In tools references in VBA I can not find that forms 2.0 object library
so I don't know if that is the problem.


Any ideas???

Thanks in advance!


Dave Peterson

Copy Status bar macro
 
Look for "Microsoft Office xx.x Object Library".

Another way to add this as a reference is to add a userform to your project.

I don't think you'll find a way to use late binding for this kind of thing.

Bongard wrote:

I originally wanted to write a macro that would copy the value in the
status bar (sum of your selection or whatever function you have chosen)
but since I only use the sum function I thought it would be easier to
just use the sum fucntion of selection and copy it to the clipboard. I
found this macro and avice from an earlier post.

Sub Macro1()

'' Keyboard Shortcut: Ctrl+Shift+S

Dim MyData As DataObject
Set MyData = New DataObject

MyData.SetText
WorksheetFunction.Sum (Selection.SpecialCells(xlCellTypeVisible))
MyData.PutInClipboard

End Sub

In order to run since MyData is earlybind, you must go to tools
reference in
the VBA editor and select Microsoft Forms 2.0 Object Library. Or you
can
change to late bind (i.e. use CreateObject)

That being said, when I try to run the macro it gives me the error
Compile Error --- User-Defined type not defined.

In tools references in VBA I can not find that forms 2.0 object library
so I don't know if that is the problem.

Any ideas???

Thanks in advance!


--

Dave Peterson


All times are GMT +1. The time now is 03:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com