Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default rename cells with a macro


Hi,

I have a worksheet in Excel. In column B I have merged cells in pairs
of 3. It starts with 3to5 then 6to8 and so on.
In these cells there are formulas referring to a worksheet called
"Begroting Calc Won". The formulas a
=ROW('Begroting Calc Won'!K11) in cells 3to5
=ROW('Begroting Calc Won'!K12) in cells 6to8
and so on.
I have a lot of these merged cells with formulas and tried to write a
macro to change the worksheet to which it refers from "Begroting Calc
Won" to "Begroting Calc Uti".
My code is below, but it won't work. The part with "i + j" is wrong I
think.
Can someone solve this problem? Thanks in advance!


Code:
--------------------
Sub EigenschappenComboBoxAanpassen()

Dim ws As Worksheet
Dim i As Long

Set ws = ActiveSheet

For i = 3 To 300 Step 3
For j = 8 To -192 Step -2
On Error Resume Next
Range("B" & i & ":B" & i + 2).UnMerge
Call LinkCombo(ws.Range("B" & i), "K" & i + j)
Range("B" & i & ":B" & i + 2).Merge
Next j
Next i

End Sub

Private Sub LinkCombo(pRange As Range, pLink As String)

Const MyFormula As String = "=ROW('Begroting Calc Uti'!"
With pRange
.Formula = MyFormula & pLink & ")"
End With

End Sub
--------------------


--
leonidas
------------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=558857

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default rename cells with a macro

did you turn on the macro recorder, then select the range and do

Edit=replace

what: 'Begroting Calc Won'
with: 'Begroting Calc Uti'

then turn off the macro recorder and look at the recorded code. Modify it
so it is more general and suits your needs.

--
Regards,
Tom Ogilvy


"leonidas" wrote:


Hi,

I have a worksheet in Excel. In column B I have merged cells in pairs
of 3. It starts with 3to5 then 6to8 and so on.
In these cells there are formulas referring to a worksheet called
"Begroting Calc Won". The formulas a
=ROW('Begroting Calc Won'!K11) in cells 3to5
=ROW('Begroting Calc Won'!K12) in cells 6to8
and so on.
I have a lot of these merged cells with formulas and tried to write a
macro to change the worksheet to which it refers from "Begroting Calc
Won" to "Begroting Calc Uti".
My code is below, but it won't work. The part with "i + j" is wrong I
think.
Can someone solve this problem? Thanks in advance!


Code:
--------------------
Sub EigenschappenComboBoxAanpassen()

Dim ws As Worksheet
Dim i As Long

Set ws = ActiveSheet

For i = 3 To 300 Step 3
For j = 8 To -192 Step -2
On Error Resume Next
Range("B" & i & ":B" & i + 2).UnMerge
Call LinkCombo(ws.Range("B" & i), "K" & i + j)
Range("B" & i & ":B" & i + 2).Merge
Next j
Next i

End Sub

Private Sub LinkCombo(pRange As Range, pLink As String)

Const MyFormula As String = "=ROW('Begroting Calc Uti'!"
With pRange
.Formula = MyFormula & pLink & ")"
End With

End Sub
--------------------


--
leonidas
------------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=558857


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default rename cells with a macro


Hi Tom,

Thanks for your advice! The replace-function works fine!


--
leonidas
------------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=558857

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
Rename of sheets by macro Harshad[_2_] Excel Discussion (Misc queries) 4 October 17th 08 01:09 PM
Rename Macro rmpete Excel Discussion (Misc queries) 3 February 11th 06 10:24 PM
Rename Cells dlaatsch Excel Discussion (Misc queries) 2 December 15th 04 03:27 PM
rename macro Lois Excel Programming 1 October 13th 04 06:04 PM
Can I rename a directory using a macro Harvey[_3_] Excel Programming 2 February 6th 04 01:49 PM


All times are GMT +1. The time now is 03:41 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"