Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
WT WT is offline
external usenet poster
 
Posts: 16
Default Quote in equation causing error

I really appreciate your help!!
I am trying to replicate this formula down the entire column in a macro.
However I continually get a compile error when it runs into the equation,
particularly the "period" ("."). How do you get quotes into a statement to
paste into a cell??

this is the code I am useing:

Range("D1").Select
ActiveCell.Formula =
"=IF(ISERROR(SEARCH(".",$C1,1)),$C1,MID($C1,1,SEAR CH(".",$C1,1)-1))"
Range("D1").Select
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Application.CutCopyMode = False

--
Thank you
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Quote in equation causing error

Double up the internal quotes.

Range("D1").Select
ActiveCell.Formula = _
"=IF(ISERROR(SEARCH(""."",$C1,1)),$C1,MID($C1,1,SE ARCH(""."",$C1,1)-1))"
Range("D1").Select
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Application.CutCopyMode = False

To get rid of selects, copy's and pastes, try this version which fills D1
down to last used row in column C

Sub Auto_Fill()
Dim Lrow As Long
With ActiveSheet
Lrow = .Range("C" & Rows.Count).End(xlUp).Row
Range("D1").Formula = _
"=IF(ISERROR(SEARCH(""."",$C1,1)),$C1,MID($C1,1,SE ARCH(""."",$C1,1)-1))"
.Range("D1:D" & Lrow).FillDown
End With
End Sub


Gord Dibben MS Excel MVP

On Thu, 5 Feb 2009 12:21:42 -0800, WT wrote:

I really appreciate your help!!
I am trying to replicate this formula down the entire column in a macro.
However I continually get a compile error when it runs into the equation,
particularly the "period" ("."). How do you get quotes into a statement to
paste into a cell??

this is the code I am useing:

Range("D1").Select
ActiveCell.Formula =
"=IF(ISERROR(SEARCH(".",$C1,1)),$C1,MID($C1,1,SEA RCH(".",$C1,1)-1))"
Range("D1").Select
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Application.CutCopyMode = False


  #3   Report Post  
Posted to microsoft.public.excel.programming
WT WT is offline
external usenet poster
 
Posts: 16
Default Quote in equation causing error

I will give both a try and thank you both for your input, very helpfull.....
--



"Gord Dibben" wrote:

Double up the internal quotes.

Range("D1").Select
ActiveCell.Formula = _
"=IF(ISERROR(SEARCH(""."",$C1,1)),$C1,MID($C1,1,SE ARCH(""."",$C1,1)-1))"
Range("D1").Select
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Application.CutCopyMode = False

To get rid of selects, copy's and pastes, try this version which fills D1
down to last used row in column C

Sub Auto_Fill()
Dim Lrow As Long
With ActiveSheet
Lrow = .Range("C" & Rows.Count).End(xlUp).Row
Range("D1").Formula = _
"=IF(ISERROR(SEARCH(""."",$C1,1)),$C1,MID($C1,1,SE ARCH(""."",$C1,1)-1))"
.Range("D1:D" & Lrow).FillDown
End With
End Sub


Gord Dibben MS Excel MVP

On Thu, 5 Feb 2009 12:21:42 -0800, WT wrote:

I really appreciate your help!!
I am trying to replicate this formula down the entire column in a macro.
However I continually get a compile error when it runs into the equation,
particularly the "period" ("."). How do you get quotes into a statement to
paste into a cell??

this is the code I am useing:

Range("D1").Select
ActiveCell.Formula =
"=IF(ISERROR(SEARCH(".",$C1,1)),$C1,MID($C1,1,SEA RCH(".",$C1,1)-1))"
Range("D1").Select
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Application.CutCopyMode = False



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Quote in equation causing error

Hi,

This corrects the formula line, note the double interior quotes

ActiveCell.Formula =
"=IF(ISERROR(SEARCH(""."",$C1,1)),$C1,MID($C1,1,SE ARCH(""."",$C1,1)-1))"

But what happens next bit of your code doesn't work. If you explain what
your trying to do someone will help

Mike

"WT" wrote:

I really appreciate your help!!
I am trying to replicate this formula down the entire column in a macro.
However I continually get a compile error when it runs into the equation,
particularly the "period" ("."). How do you get quotes into a statement to
paste into a cell??

this is the code I am useing:

Range("D1").Select
ActiveCell.Formula =
"=IF(ISERROR(SEARCH(".",$C1,1)),$C1,MID($C1,1,SEAR CH(".",$C1,1)-1))"
Range("D1").Select
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Application.CutCopyMode = False

--
Thank you

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Quote in equation causing error

Hi,

Looking a bit more closely are you trying ti fill down as far as there are
data in column C?

Dim MyRange As Range
Set MyRange = Range("D1:D" & Cells(Rows.Count, "C").End(xlUp).Row)
MyRange.Formula =
"=IF(ISERROR(SEARCH(""."",$C1,1)),$C1,MID($C1,1,SE ARCH(""."",$C1,1)-1))"


Mike
"Mike H" wrote:

Hi,

This corrects the formula line, note the double interior quotes

ActiveCell.Formula =
"=IF(ISERROR(SEARCH(""."",$C1,1)),$C1,MID($C1,1,SE ARCH(""."",$C1,1)-1))"

But what happens next bit of your code doesn't work. If you explain what
your trying to do someone will help

Mike

"WT" wrote:

I really appreciate your help!!
I am trying to replicate this formula down the entire column in a macro.
However I continually get a compile error when it runs into the equation,
particularly the "period" ("."). How do you get quotes into a statement to
paste into a cell??

this is the code I am useing:

Range("D1").Select
ActiveCell.Formula =
"=IF(ISERROR(SEARCH(".",$C1,1)),$C1,MID($C1,1,SEAR CH(".",$C1,1)-1))"
Range("D1").Select
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Application.CutCopyMode = False

--
Thank you



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
What's causing error message? Jim Tibbetts Excel Worksheet Functions 4 November 12th 08 06:13 PM
What's causing error message? Jim Tibbetts Excel Programming 1 November 12th 08 05:55 PM
Single quote in filename causing problems geoff_ness Excel Programming 5 October 30th 08 10:36 AM
#NAME? error with MSN stock quote function Travis Excel Discussion (Misc queries) 0 October 8th 08 05:41 PM
VLOOKUP Formula causing an error japc90 Excel Discussion (Misc queries) 2 July 25th 06 11:36 PM


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