# Thread: Convert formula's to R1C1

1. Hi,

I have adopted a trick to convert formula's to R1C1 type for using in VBA by setting the formula up in the desired location, and pressing F2 on the cell whilst the macro recorder is on, which provides me with my vba.

The following 2 formulas report "Unable to record" whilst attempting the above.

Code:
`=SUMPRODUCT((\$C4=\$C\$4:\$C\$174)*(F4<F\$4:F\$174))+1&IF(OR(MOD(SUMPRODUCT((\$C4=\$C\$4:\$C\$174)*(F4<F\$4:F\$174))+1,100)={11,12,13}),"th",CHOOSE(MIN(5,RIGHT(SUMPRODUCT((\$C4=\$C\$4:\$C\$174)*(F4<F\$4:F\$174))+1)+1),"th","st","nd","rd","th"))`
Code:
`=SUMPRODUCT((\$D4=\$D\$4:\$D\$174)*(F4<F\$4:F\$174))+1&IF(OR(MOD(SUMPRODUCT((\$D4=\$D\$4:\$D\$174)*(F4<F\$4:F\$174))+1,100)={11,12,13}),"th",CHOOSE(MIN(5,RIGHT(SUMPRODUCT((\$D4=\$D\$4:\$D\$174)*(F4<F\$4:F\$174))+1)+1),"th","st","nd","rd","th"))`
Firstly, why is the recorder unable to record this?, and second, please would a kind lounger assist me with the conversion.

Thanks

Update:

I no longer need the conversion, but I am still curious as to why the recorder will not record the action?

2. The formulas are too long for the macro recorder.

3. You can also go to the VBE and hit control+g to get into the immediate pane and type ?Activecell.FormulaR1C1 and hit enter.

4. You could use this sub to copy the active cell's formula to the clipboard in R1C1 format:
Code:
```Public Sub CopyCellContents_Sub()
Dim objData As Object
Set objData = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")

'Same as f2+copy contents.

With objData
.SetText Replace(ActiveCell.FormulaR1C1, """", """""")
.PutInClipboard
End With

End Sub```

5. [quote name='rory' post='799925' date='26-Oct-2009 05:15']
Code:
`	  Set objData = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")`
[/quote]

Hi Rory
I am confused. Can you explain {1C3B4210-F441-11CE-B9EA-00AA006B1A69} for me?

6. It's the GUID for the MSForms.DataObject. That is the only way I know of to late bind one - you could also simply set a reference to the Forms object library and then use:
Code:
`Set obJData = New MSForms.DataObject`

7. {1C3B4210-F441-11CE-B9EA-00AA006B1A69} is the GUID (unique ID) of the Microsoft Forms DataObject (you can find it in the registry, using RegEdit)
Rory's code is a way to create an instance of DataObject without having to set a reference to the MS Forms 2.n Object Library.

8. [quote name='rory' post='799969' date='26-Oct-2009 12:08']It's the GUID for the MSForms.DataObject. That is the only way I know of to late bind one - you could also simply set a reference to the Forms object library and then use:
Code:
`Set obJData = New MSForms.DataObject`
[/quote]

Thank you Rory and Hans.

9. Thanks all, a useful topic to come back to next time I am in the same position.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•