Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
pol pol is offline
external usenet poster
 
Posts: 129
Default To store the formula in a string

Please help to store the followng formula in a string . I did the following
ways but not working . The purpose of the formula to convert string into
date format. The formlula is working independantly. But it didnot working
when I am trying to store in a variable.

myFormula =
"=IF(LEFT(CELL("format",RC[1]),1)="D",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"

Sub sizeonly()
Dim res As Variant
Dim wks As Worksheet
Dim LastRow As Long
Dim myFormula As String
Set wks = ActiveSheet

With wks

res = Application.Match("DATE", .Rows(2), 0)

LastRow = .Cells(.Rows.Count, res).End(xlUp).Row

.Columns(res).Insert

'add header in row 1
.Cells(2, res).Value = "YEAR"

myFormula =
"=IF(LEFT(CELL("format",RC[1]),1)="D",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))" 'Here is not working pls help

.Range(.Cells(3, res), .Cells(LastRow, res)).FormulaR1C1 = myFormula
.Columns(res).AutoFit


End With

End Sub

With thanks

Polachan Paily

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,420
Default To store the formula in a string

Sub sizeonly()
Dim res As Variant
Dim wks As Worksheet
Dim LastRow As Long
Dim myFormula As String
Set wks = ActiveSheet

With wks

res = Application.Match("DATE", .Rows(2), 0)

LastRow = .Cells(.Rows.Count, res).End(xlUp).Row

.Columns(res).Insert

'add header in row 1
.Cells(2, res).Value = "YEAR"

myFormula = _
"=IF(LEFT(CELL("format",RC[1]),1)=""D"",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"
'Here is not working pls help

.Range(.Cells(3, res), .Cells(LastRow, res)).FormulaR1C1 = myFormula
.Columns(res).AutoFit


End With

End Sub


--
__________________________________
HTH

Bob

"pol" wrote in message
...
Please help to store the followng formula in a string . I did the
following
ways but not working . The purpose of the formula to convert string into
date format. The formlula is working independantly. But it didnot working
when I am trying to store in a variable.

myFormula =
"=IF(LEFT(CELL("format",RC[1]),1)="D",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"

Sub sizeonly()
Dim res As Variant
Dim wks As Worksheet
Dim LastRow As Long
Dim myFormula As String
Set wks = ActiveSheet

With wks

res = Application.Match("DATE", .Rows(2), 0)

LastRow = .Cells(.Rows.Count, res).End(xlUp).Row

.Columns(res).Insert

'add header in row 1
.Cells(2, res).Value = "YEAR"

myFormula =
"=IF(LEFT(CELL("format",RC[1]),1)="D",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"
'Here is not working pls help

.Range(.Cells(3, res), .Cells(LastRow, res)).FormulaR1C1 =
myFormula
.Columns(res).AutoFit


End With

End Sub

With thanks

Polachan Paily



  #3   Report Post  
Posted to microsoft.public.excel.misc
pol pol is offline
external usenet poster
 
Posts: 129
Default To store the formula in a string

Still it is not working , Syntax error is coming

"Bob Phillips" wrote:

Sub sizeonly()
Dim res As Variant
Dim wks As Worksheet
Dim LastRow As Long
Dim myFormula As String
Set wks = ActiveSheet

With wks

res = Application.Match("DATE", .Rows(2), 0)

LastRow = .Cells(.Rows.Count, res).End(xlUp).Row

.Columns(res).Insert

'add header in row 1
.Cells(2, res).Value = "YEAR"

myFormula = _
"=IF(LEFT(CELL("format",RC[1]),1)=""D"",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"
'Here is not working pls help

.Range(.Cells(3, res), .Cells(LastRow, res)).FormulaR1C1 = myFormula
.Columns(res).AutoFit


End With

End Sub


--
__________________________________
HTH

Bob

"pol" wrote in message
...
Please help to store the followng formula in a string . I did the
following
ways but not working . The purpose of the formula to convert string into
date format. The formlula is working independantly. But it didnot working
when I am trying to store in a variable.

myFormula =
"=IF(LEFT(CELL("format",RC[1]),1)="D",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"

Sub sizeonly()
Dim res As Variant
Dim wks As Worksheet
Dim LastRow As Long
Dim myFormula As String
Set wks = ActiveSheet

With wks

res = Application.Match("DATE", .Rows(2), 0)

LastRow = .Cells(.Rows.Count, res).End(xlUp).Row

.Columns(res).Insert

'add header in row 1
.Cells(2, res).Value = "YEAR"

myFormula =
"=IF(LEFT(CELL("format",RC[1]),1)="D",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"
'Here is not working pls help

.Range(.Cells(3, res), .Cells(LastRow, res)).FormulaR1C1 =
myFormula
.Columns(res).AutoFit


End With

End Sub

With thanks

Polachan Paily




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,420
Default To store the formula in a string

I missed one

Sub sizeonly()
Dim res As Variant
Dim wks As Worksheet
Dim LastRow As Long
Dim myFormula As String
Set wks = ActiveSheet

With wks

res = Application.Match("DATE", .Rows(2), 0)

LastRow = .Cells(.Rows.Count, res).End(xlUp).Row

.Columns(res).Insert

'add header in row 1
.Cells(2, res).Value = "YEAR"

myFormula = _
"=IF(LEFT(CELL(""format"",RC[1]),1)=""D"",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"
.Range(.Cells(3, res), .Cells(LastRow, res)).FormulaR1C1 = myFormula
.Columns(res).AutoFit
End With

End Sub


--
__________________________________
HTH

Bob

"pol" wrote in message
...
Still it is not working , Syntax error is coming

"Bob Phillips" wrote:

Sub sizeonly()
Dim res As Variant
Dim wks As Worksheet
Dim LastRow As Long
Dim myFormula As String
Set wks = ActiveSheet

With wks

res = Application.Match("DATE", .Rows(2), 0)

LastRow = .Cells(.Rows.Count, res).End(xlUp).Row

.Columns(res).Insert

'add header in row 1
.Cells(2, res).Value = "YEAR"

myFormula = _
"=IF(LEFT(CELL("format",RC[1]),1)=""D"",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"
'Here is not working pls help

.Range(.Cells(3, res), .Cells(LastRow, res)).FormulaR1C1 =
myFormula
.Columns(res).AutoFit


End With

End Sub


--
__________________________________
HTH

Bob

"pol" wrote in message
...
Please help to store the followng formula in a string . I did the
following
ways but not working . The purpose of the formula to convert string
into
date format. The formlula is working independantly. But it didnot
working
when I am trying to store in a variable.

myFormula =
"=IF(LEFT(CELL("format",RC[1]),1)="D",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"

Sub sizeonly()
Dim res As Variant
Dim wks As Worksheet
Dim LastRow As Long
Dim myFormula As String
Set wks = ActiveSheet

With wks

res = Application.Match("DATE", .Rows(2), 0)

LastRow = .Cells(.Rows.Count, res).End(xlUp).Row

.Columns(res).Insert

'add header in row 1
.Cells(2, res).Value = "YEAR"

myFormula =
"=IF(LEFT(CELL("format",RC[1]),1)="D",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"
'Here is not working pls help

.Range(.Cells(3, res), .Cells(LastRow, res)).FormulaR1C1 =
myFormula
.Columns(res).AutoFit


End With

End Sub

With thanks

Polachan Paily






  #5   Report Post  
Posted to microsoft.public.excel.misc
pol pol is offline
external usenet poster
 
Posts: 129
Default To store the formula in a string

thanks a lot

"Bob Phillips" wrote:

I missed one

Sub sizeonly()
Dim res As Variant
Dim wks As Worksheet
Dim LastRow As Long
Dim myFormula As String
Set wks = ActiveSheet

With wks

res = Application.Match("DATE", .Rows(2), 0)

LastRow = .Cells(.Rows.Count, res).End(xlUp).Row

.Columns(res).Insert

'add header in row 1
.Cells(2, res).Value = "YEAR"

myFormula = _
"=IF(LEFT(CELL(""format"",RC[1]),1)=""D"",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"
.Range(.Cells(3, res), .Cells(LastRow, res)).FormulaR1C1 = myFormula
.Columns(res).AutoFit
End With

End Sub


--
__________________________________
HTH

Bob

"pol" wrote in message
...
Still it is not working , Syntax error is coming

"Bob Phillips" wrote:

Sub sizeonly()
Dim res As Variant
Dim wks As Worksheet
Dim LastRow As Long
Dim myFormula As String
Set wks = ActiveSheet

With wks

res = Application.Match("DATE", .Rows(2), 0)

LastRow = .Cells(.Rows.Count, res).End(xlUp).Row

.Columns(res).Insert

'add header in row 1
.Cells(2, res).Value = "YEAR"

myFormula = _
"=IF(LEFT(CELL("format",RC[1]),1)=""D"",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"
'Here is not working pls help

.Range(.Cells(3, res), .Cells(LastRow, res)).FormulaR1C1 =
myFormula
.Columns(res).AutoFit


End With

End Sub


--
__________________________________
HTH

Bob

"pol" wrote in message
...
Please help to store the followng formula in a string . I did the
following
ways but not working . The purpose of the formula to convert string
into
date format. The formlula is working independantly. But it didnot
working
when I am trying to store in a variable.

myFormula =
"=IF(LEFT(CELL("format",RC[1]),1)="D",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"

Sub sizeonly()
Dim res As Variant
Dim wks As Worksheet
Dim LastRow As Long
Dim myFormula As String
Set wks = ActiveSheet

With wks

res = Application.Match("DATE", .Rows(2), 0)

LastRow = .Cells(.Rows.Count, res).End(xlUp).Row

.Columns(res).Insert

'add header in row 1
.Cells(2, res).Value = "YEAR"

myFormula =
"=IF(LEFT(CELL("format",RC[1]),1)="D",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"
'Here is not working pls help

.Range(.Cells(3, res), .Cells(LastRow, res)).FormulaR1C1 =
myFormula
.Columns(res).AutoFit


End With

End Sub

With thanks

Polachan Paily







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can one store a string in a Array element? [email protected] Excel Discussion (Misc queries) 1 April 17th 07 12:53 PM
store address in a cell and use it in formula gbalamani Excel Discussion (Misc queries) 1 April 17th 07 10:36 AM
store inventory sheet(ex:sports equipment store) vardan Excel Worksheet Functions 1 October 11th 06 12:51 AM
Store formula in Cell ggant Excel Discussion (Misc queries) 3 December 14th 05 08:11 PM
Store formula in Cell CLR Excel Discussion (Misc queries) 0 December 14th 05 05:45 PM


All times are GMT +1. The time now is 12:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"