Can do Formula with in Macros?

Kele

Board Regular
Joined
May 21, 2008
Messages
64
Hi,

I have a Macro that run fine, it text to columns and then copies a stored Formula from E1 and auto fills the column.

What i want is to store the Formula in the macro but i dont know how, every time i try it give me erros.

The Formula stored in E1 is ="“admin”;”base”;”Default”;”simple”;"""&""""&A1&""""&";"&""""&B1&""""&";"&""""&C1&""""&";"&""""&D1&""""

My current macro is below any help would be great as i can never get formula working in macros!!!

Kele

Sub SplitOut()
'
' SplitOut Macro
'
LastRow = Range("A65536").End(xlUp).Row

Columns("A:A").Select
Application.CutCopyMode = False
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1))
Range("E1").AutoFill Destination:=Range("E1:E" & LastRow)

End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
delete the formula from E1 and try running this macro

Sub SplitOut()
'
' SplitOut Macro
'
LastRow = Range("A65536").End(xlUp).Row

Columns("A:A").Select
Application.CutCopyMode = False
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1))
Range("E1").FormulaR1C1 = "=""“admin”;”base”;”Default”;”simple”;""""""&""""""""&RC[-4]&""""""""&"";""&""""""""&RC[-3]&""""""""&"";""&""""""""&RC[-2]&""""""""&"";""&""""""""&RC[-1]&"""""""""
Range("E1").AutoFill Destination:=Range("E1:E" & LastRow)

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,508
Messages
6,179,188
Members
452,893
Latest member
denay

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