Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Macro fails in different WB

Here's a macro that works perfectly in one of my workbooks:

Sub UnsplitNames()
Dim myCell As Range
For Each myCell In Range("E6", Range("E65536").End(xlUp))
myCell(1, 13).FormulaR1C1 = "=RC[-14] & "", "" & RC[-13]"
Next myCell
End Sub

Here's the same macro slightly hacked as added to a different WB:

Sub UnsplitNames()
Dim myCell As Range
For Each myCell In Range("A2", Range("A65536").End(xlUp))
myCell(1, 27).FormulaR1C1 = "=RC[-26] & "", "" & RC[-25]"
Next myCell
End Sub

...and it returns "=RC[-26] & "", "" & RC[-25]" in pretty blue text in every
cell.

Where did I go wrong, Mother darling?
--
Dave
Temping with Staffmark
in Rock Hill, SC
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Macro fails in different WB

Your cells are formatted as Text, so the formulae aren't parsed. Try:

Public Sub UnsplitNames()
Dim myCell As Range
With Range("A2", Range("A" & Rows.Count).End(xlUp))
.Offset(0, 26).NumberFormat = "General"
For Each myCell In .Cells
myCell(1, 27).FormulaR1C1 = "=RC[-26] & "", "" & RC[-25]"
Next myCell
End With
End Sub


In article ,
Dave Birley wrote:

Here's a macro that works perfectly in one of my workbooks:

Sub UnsplitNames()
Dim myCell As Range
For Each myCell In Range("E6", Range("E65536").End(xlUp))
myCell(1, 13).FormulaR1C1 = "=RC[-14] & "", "" & RC[-13]"
Next myCell
End Sub

Here's the same macro slightly hacked as added to a different WB:

Sub UnsplitNames()
Dim myCell As Range
For Each myCell In Range("A2", Range("A65536").End(xlUp))
myCell(1, 27).FormulaR1C1 = "=RC[-26] & "", "" & RC[-25]"
Next myCell
End Sub

..and it returns "=RC[-26] & "", "" & RC[-25]" in pretty blue text in every
cell.

Where did I go wrong, Mother darling?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Macro fails in different WB

Thanks! That solved the problem just fine.

One question, not a "deal breaker", when the new column was populated, the
text was colored blue, whereas there is nothing colored blue anywhere else on
the WS. To fix it, of course, I just selected the whole column and set the
color to Auto, and presto changeo, everything went black <g!

I gave the macro a hot key and ran it on some other Sheets, without the
color thing happening -- could it be merely that when the text was originally
displyed as code in blue, it set the cell color to blue?
--
Dave
Temping with Staffmark
in Rock Hill, SC


"JE McGimpsey" wrote:

Your cells are formatted as Text, so the formulae aren't parsed. Try:

Public Sub UnsplitNames()
Dim myCell As Range
With Range("A2", Range("A" & Rows.Count).End(xlUp))
.Offset(0, 26).NumberFormat = "General"
For Each myCell In .Cells
myCell(1, 27).FormulaR1C1 = "=RC[-26] & "", "" & RC[-25]"
Next myCell
End With
End Sub


In article ,
Dave Birley wrote:

Here's a macro that works perfectly in one of my workbooks:

Sub UnsplitNames()
Dim myCell As Range
For Each myCell In Range("E6", Range("E65536").End(xlUp))
myCell(1, 13).FormulaR1C1 = "=RC[-14] & "", "" & RC[-13]"
Next myCell
End Sub

Here's the same macro slightly hacked as added to a different WB:

Sub UnsplitNames()
Dim myCell As Range
For Each myCell In Range("A2", Range("A65536").End(xlUp))
myCell(1, 27).FormulaR1C1 = "=RC[-26] & "", "" & RC[-25]"
Next myCell
End Sub

..and it returns "=RC[-26] & "", "" & RC[-25]" in pretty blue text in every
cell.

Where did I go wrong, Mother darling?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Macro fails in different WB

Just realized why the macro worked in the first WB and not in the second -- I
had set all cells in the first WB to General.

See, I'm learning <g!
--
Dave
Temping with Staffmark
in Rock Hill, SC


"JE McGimpsey" wrote:

Your cells are formatted as Text, so the formulae aren't parsed. Try:

Public Sub UnsplitNames()
Dim myCell As Range
With Range("A2", Range("A" & Rows.Count).End(xlUp))
.Offset(0, 26).NumberFormat = "General"
For Each myCell In .Cells
myCell(1, 27).FormulaR1C1 = "=RC[-26] & "", "" & RC[-25]"
Next myCell
End With
End Sub


In article ,
Dave Birley wrote:

Here's a macro that works perfectly in one of my workbooks:

Sub UnsplitNames()
Dim myCell As Range
For Each myCell In Range("E6", Range("E65536").End(xlUp))
myCell(1, 13).FormulaR1C1 = "=RC[-14] & "", "" & RC[-13]"
Next myCell
End Sub

Here's the same macro slightly hacked as added to a different WB:

Sub UnsplitNames()
Dim myCell As Range
For Each myCell In Range("A2", Range("A65536").End(xlUp))
myCell(1, 27).FormulaR1C1 = "=RC[-26] & "", "" & RC[-25]"
Next myCell
End Sub

..and it returns "=RC[-26] & "", "" & RC[-25]" in pretty blue text in every
cell.

Where did I go wrong, Mother darling?


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
TEXT-formula in VB Macro fails [email protected] Excel Programming 4 August 3rd 06 04:13 PM
Macro fails in network Tom H[_2_] Excel Programming 1 May 25th 06 05:23 PM
Macro Suddenly Fails Bill Martin Excel Discussion (Misc queries) 2 September 16th 05 01:55 PM
Macro Fails to Run Correctly JK Excel Programming 3 August 20th 04 09:40 PM
Macro fails without VB help files Michael Miazga[_2_] Excel Programming 0 July 22nd 03 04:10 PM


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