Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #9211 > unrolled thread
| Started by | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| First post | 2012-03-23 06:35 +0000 |
| Last post | 2012-04-01 07:40 +0000 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Exporting a formula to Excel via copypaste Bob Hanlon <hanlonr357@gmail.com> - 2012-03-23 06:35 +0000
Re: Exporting a formula to Excel via copypaste Murta <rodrigomurtax@gmail.com> - 2012-03-26 06:49 +0000
Re: Exporting a formula to Excel via copypaste Thomas Melehan <tpmelehan@gmail.com> - 2012-03-28 05:34 +0000
Re: Exporting a formula to Excel via copypaste Murta <rodrigomurtax@gmail.com> - 2012-04-01 07:40 +0000
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Date | 2012-03-23 06:35 +0000 |
| Subject | Re: Exporting a formula to Excel via copypaste |
| Message-ID | <jkh5jg$jtr$1@smc.vnet.net> |
The two parts of the constant term will automatically combine. InputForm uses asterisks. -0.00488067 + 0.000981042 dff + 0.000109406 dff^2 + 1.83066*10^-8 // InputForm -0.0048806516934 + 0.000981042*dff + 0.000109406*dff^2 My Excel (Excel for Mac 2011) accepts numbers of the form 1.83066*10^-8 Bob Hanlon On Thu, Mar 22, 2012 at 6:50 AM, <ruesche83@gmail.com> wrote: > Hi there > > I'm trying to copy a fromula from mathematica a and paste it to excel. It is a polynomial. Something like: > > -0.00488067+0.000981042 dff+0.000109406 dff^2+1.83066*10^-8 > > Now, there are two problems: > - The exponential is written as 10^-8. Which is not compatible with excel. This issue can be solve by using ScientificForm. > - The second problem: Excel wants asterisks (*) for the multiplication. This is solved by doing it this way: ScientificForm[rhofit, NumberMultiplier -> "*"] > > Now, the problem is, that NumberMultiplier only adds asterisks where you have number, but not if you have variables. Any idea to replace the spaces with asterisks? > > Any help would be highly appreciated. > Philipp > -- Bob Hanlon
[toc] | [next] | [standalone]
| From | Murta <rodrigomurtax@gmail.com> |
|---|---|
| Date | 2012-03-26 06:49 +0000 |
| Message-ID | <jkp3h3$kvq$1@smc.vnet.net> |
| In reply to | #9211 |
On 23 mar, 03:35, Bob Hanlon <hanlonr...@gmail.com> wrote:
> The two parts of the constant term will automatically combine.
> InputForm uses asterisks.
>
> -0.00488067 + 0.000981042 dff + 0.000109406 dff^2 + 1.83066*10^-8 // InputForm
>
> -0.0048806516934 + 0.000981042*dff + 0.000109406*dff^2
>
> My Excel (Excel for Mac 2011) accepts numbers of the form 1.83066*10^-8
>
> Bob Hanlon
>
>
>
>
>
>
>
>
>
> On Thu, Mar 22, 2012 at 6:50 AM, <ruesch...@gmail.com> wrote:
> > Hi there
>
> > I'm trying to copy a fromula from mathematica a and paste it to excel. It is a polynomial. Something like:
>
> > -0.00488067+0.000981042 dff+0.000109406 dff^2+1.83066*10^-8
>
> > Now, there are two problems:
> > - The exponential is written as 10^-8. Which is not compatible with excel. This issue can be solve by using ScientificForm.
> > - The second problem: Excel wants asterisks (*) for the multiplication. This is solved by doing it this way: ScientificForm[rhofit, NumberMultiplier -> "*"]
>
> > Now, the problem is, that NumberMultiplier only adds asterisks where you have number, but not if you have variables. Any idea to replace the spaces with asterisks?
>
> > Any help would be highly appreciated.
> > Philipp
>
> --
> Bob Hanlon
Hi All
I use excel a lot, so I create this function to copy things to
clipboard:
CopyTable2Clipboard[expr_] := Module[{nb, expr2 = Map[NumberForm[#,
NumberPoint -> ","] &, expr, {-1}]//TableForm},
nb = CreateDocument[Null, Visible -> False, WindowSelected ->
True];
NotebookWrite[nb, Cell[ToBoxes@expr2, "Output"], All];
FrontEndExecute[FrontEndToken[nb, "CopySpecial"]];
NotebookClose@nb];
I use it in one personal pack, so it's always avaliable when
mathematica starts.
My excel use comma as decimal separator, so I have to use this
Map[NumberForm[#, NumberPoint -> ","] part, maybe you not.
best regards
Murta
[toc] | [prev] | [next] | [standalone]
| From | Thomas Melehan <tpmelehan@gmail.com> |
|---|---|
| Date | 2012-03-28 05:34 +0000 |
| Message-ID | <jku7u3$8js$1@smc.vnet.net> |
| In reply to | #9211 |
Murta: Your function was helpful. Do you happen to have one that goes
from Excel to Mathematica?
On Mar 26, 2012, at 2:47 AM, Murta wrote:
> On 23 mar, 03:35, Bob Hanlon <hanlonr...@gmail.com> wrote:
>> The two parts of the constant term will automatically combine.
>> InputForm uses asterisks.
>>
>> -0.00488067 + 0.000981042 dff + 0.000109406 dff^2 + 1.83066*10^-8 // InputForm
>>
>> -0.0048806516934 + 0.000981042*dff + 0.000109406*dff^2
>>
>> My Excel (Excel for Mac 2011) accepts numbers of the form 1.83066*10^-8
>>
>> Bob Hanlon
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Thu, Mar 22, 2012 at 6:50 AM, <ruesch...@gmail.com> wrote:
>>> Hi there
>>
>>> I'm trying to copy a fromula from mathematica a and paste it to excel. It is a polynomial. Something like:
>>
>>> -0.00488067+0.000981042 dff+0.000109406 dff^2+1.83066*10^-8
>>
>>> Now, there are two problems:
>>> - The exponential is written as 10^-8. Which is not compatible with excel. This issue can be solve by using ScientificForm.
>>> - The second problem: Excel wants asterisks (*) for the multiplication. This is solved by doing it this way: ScientificForm[rhofit, NumberMultiplier -> "*"]
>>
>>> Now, the problem is, that NumberMultiplier only adds asterisks where you have number, but not if you have variables. Any idea to replace the spaces with asterisks?
>>
>>> Any help would be highly appreciated.
>>> Philipp
>>
>> --
>> Bob Hanlon
>
> Hi All
> I use excel a lot, so I create this function to copy things to
> clipboard:
>
> CopyTable2Clipboard[expr_] := Module[{nb, expr2 = Map[NumberForm[#,
> NumberPoint -> ","] &, expr, {-1}]//TableForm},
> nb = CreateDocument[Null, Visible -> False, WindowSelected ->
> True];
> NotebookWrite[nb, Cell[ToBoxes@expr2, "Output"], All];
> FrontEndExecute[FrontEndToken[nb, "CopySpecial"]];
> NotebookClose@nb];
>
> I use it in one personal pack, so it's always avaliable when
> mathematica starts.
> My excel use comma as decimal separator, so I have to use this
> Map[NumberForm[#, NumberPoint -> ","] part, maybe you not.
> best regards
> Murta
>
[toc] | [prev] | [next] | [standalone]
| From | Murta <rodrigomurtax@gmail.com> |
|---|---|
| Date | 2012-04-01 07:40 +0000 |
| Message-ID | <jl90ov$mr2$1@smc.vnet.net> |
| In reply to | #9211 |
On Mar 28, 2:34 am, Thomas Melehan <tpmele...@gmail.com> wrote:
> Murta: Your function was helpful. Do you happen to have one that goes
> fromExcelto Mathematica?
>
> On Mar 26, 2012, at 2:47 AM,Murtawrote:
>
>
>
>
>
>
>
> > On 23 mar, 03:35, Bob Hanlon <hanlonr...@gmail.com> wrote:
> >> The two parts of the constant term will automatically combine.
> >> InputForm uses asterisks.
>
> >> -0.00488067 + 0.000981042 dff + 0.000109406 dff^2 + 1.83066*10^-8 // InputForm
>
> >> -0.0048806516934 + 0.000981042*dff + 0.000109406*dff^2
>
> >> MyExcel(Excelfor Mac 2011) accepts numbers of the form 1.83066*10^-8
>
> >> Bob Hanlon
>
> >> On Thu, Mar 22, 2012 at 6:50 AM, <ruesch...@gmail.com> wrote:
> >>> Hi there
>
> >>> I'm trying to copy a fromula from mathematica a and paste it toexcel. It is a polynomial. Something like:
>
> >>> -0.00488067+0.000981042 dff+0.000109406 dff^2+1.83066*10^-8
>
> >>> Now, there are two problems:
> >>> - The exponential is written as 10^-8. Which is not compatible with excel. This issue can be solve by using ScientificForm.
> >>> - The second problem:Excelwants asterisks (*) for the multiplication. This is solved by doing it this way: ScientificForm[rhofit, NumberMultiplier -> "*"]
>
> >>> Now, the problem is, that NumberMultiplier only adds asterisks where you have number, but not if you have variables. Any idea to replace the spaces with asterisks?
>
> >>> Any help would be highly appreciated.
> >>> Philipp
>
> >> --
> >> Bob Hanlon
>
> > Hi All
> > I useexcela lot, so I create this function to copy things to
> > clipboard:
>
> > CopyTable2Clipboard[expr_] := Module[{nb, expr2 = Map[NumberForm[#,
> > NumberPoint -> ","] &, expr, {-1}]//TableForm},
> > nb = CreateDocument[Null, Visible -> False, WindowSelected ->
> > True];
> > NotebookWrite[nb, Cell[ToBoxes@expr2, "Output"], All];
> > FrontEndExecute[FrontEndToken[nb, "CopySpecial"]];
> > NotebookClose@nb];
>
> > I use it in one personal pack, so it's always avaliable when
> > mathematica starts.
> > Myexceluse comma as decimal separator, so I have to use this
> > Map[NumberForm[#, NumberPoint -> ","] part, maybe you not.
> > best regards
> >Murta
Nice that it was useful!
Yes, I have one function for that, it's one of my favorites excel
ones. I leave it in my personal macro workbook, and have a special
keyboard shortcut for call it.
Pay attention for you decimal system separator. Here in Brazil we use
comma for decimal separator. You can change it in:
Replace(Format(v(r, C), "@"), ",", ".")
There is the VBA
Best Regards
Murta
--------------------------------------------------------------------------- --------------------------------------------------------------------------- ---------------------------
Private Sub Excel_To_Mathematica()
'Modified by Rodrigo Murta em 03/2011
'Usable for "," as decimal separator
'Eliminate Bug for Big and Small Numbers
'Elminate Line Transpose Limitations
'I use CTRL + SHIFT + C for copy
'// = = = = = = = = = = = = = = = = = ==
= = = = = = = = = = = = = = =
= =
'// Use:
'// Select 1 Area of data in Excel, and run this macro.
'// Program will place data in Clipboard in Mathematica format.{ }
'// Switch to Mathematica and Paste
'// Important:
'// Add the VBA project: "Microsoft Forms 2.0 object library"
'// Note:
'// This may not work with older versions of Excel.
'// Newer versions of Excel have the "Join" function and are
'// able to Transpose more than 5461 cells
'// Program by: Dana DeLouis Microsoft Excel MVP
'// = = = = = = = = = = = = = = = = = ==
= = = = = = = = = = = = = = =
= =
Dim ClipBoard As New DataObject
Dim Nr As Long '# of Rows
Dim Nc As Long '# of Columns
Dim r As Long ' Row Pointer
Dim C As Long ' Column Pointer
Dim T() 'Temporary Storage
Dim Tc() 'Temporary Storage
Dim v As Variant 'Holds the data from Worksheet
Dim s As String
Dim ButtonClicked As Long
Const DQ As String = """" 'Double Quotes: 4 of them!
Dim transp 'Temp Array for Transpose Case
Application.ScreenUpdating = False
'// A little error checking first...
If TypeName(selection) <> "Range" Then
MsgBox "Select a Range first"
Exit Sub
End If
If selection.Areas.Count > 1 Then
MsgBox "Select only 1 area. Macro will Exit"
Exit Sub
End If
'// Load data into an Array
If selection.Cells.Count = 1 Then
ReDim v(1 To 1, 1 To 1)
v(1, 1) = selection
Else
v = selection
End If
'// Get number of Rows & Columns
Nr = UBound(v, 1)
Nc = UBound(v, 2)
If Nc = 1 And Nr > 1 Then
ButtonClicked = MsgBox("Transform Vectors in Columns?", vbYesNo)
End If
'// Put quotes around text
For r = 1 To Nr
For C = 1 To Nc
If IsNumeric(v(r, C)) Then
v(r, C) = Replace(Replace(Format(v(r, C), "@"), ",",
"."), "@", "")
v(r, C) = Replace(v(r, C), "E", "*10^")
Else
v(r, C) = DQ & v(r, C) & DQ
End If
Next C
Next r
If ButtonClicked = vbYes Then
ReDim tempArray(1 To Nr)
For i = 1 To Nr
tempArray(i) = v(i, 1)
Next
v = tempArray
s = "{" & Join(v, ",") & "}"
Else
ReDim T(1 To Nr)
ReDim Tc(1 To Nc)
For r = 1 To Nr
For C = 1 To Nc
Tc(C) = v(r, C)
Next
T(r) = "{" & Join(Tc(), ",") & "}"
Next
s = Join(T, ",")
If Nr > 1 Then s = "{" & s & "}"
End If
ClipBoard.SetText s
ClipBoard.PutInClipboard
Application.ScreenUpdating = True
'Application.StatusBar = "data copied"
'Application.StatusBar = False
End Sub
Private Function TransposeDim(v As Variant) As Variant
' Custom Function to Transpose a 1-based array (v)
Dim x As Long, y As Long, Xupper As Long, Yupper As Long
Dim tempArray()
Xupper = UBound(v, 2)
Yupper = UBound(v, 1)
ReDim tempArray(1 To Xupper, 1 To Yupper)
For x = 1 To Xupper
For y = 1 To Yupper
tempArray(x, y) = v(y, x)
Next y
Next x
TransposeDim = tempArray
End Function
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web