Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 293
Default Copy And Paste Macro Syntax Problem

Greetings,

I found a solution to my copy and paste problem in the archives.

the problem is that I need to paste an empty cell as a choice in my IF
statement. Here is the formula in the cell called pfCell_1:

=IF(OFFSET(clStart,pfDisc,1)=0,"",OFFSET(clStart,p fDisc,1))

After I run the macro to overwrite the contents of the 79 named
ranges, this is what is returned in pfCell_1:

=IF(OFFSET(clStart,pfDisc,1)=0,,OFFSET(clStart,pfD isc,1))

Notice the missing "" marks.

Here is the macro that changes all 79 named ranges at one time:

Sub RecoverFormulas()
Dim i As Integer

With ActiveSheet
For i = 1 To 79
If Not i = 26 Then .Range("pfCell_" & i).Formula = _
"=IF(OFFSET(clStart,pfDisc," & i & _
")=0,,OFFSET(clStart,pfDisc," & i & "))"
Next i
End With

End Sub

When I tried to put "" between the ,,'s, debug kicked in and stopped
the macro with an error message - it did not like the ""'s !!!

How can This be rewritten so the I get empty named range if the result
is 0???

Any ideas, suggestions or thought on this matter?

Any help is appreciated.

-Minitman
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 419
Default Copy And Paste Macro Syntax Problem

Minitman,

You need to return double qotes inside of a string (a string is surrounded
by double quotes).

So when you insert 2 double quotes between the commas...well I'm not quite
sure what it is trying to do. To return double quotes inside a string, you
need to double, and sometimes triple or quadruple your double quotes,
depending on how many you need and where you need them. In your case, you
might try 4 quotes ("""").

But I find the whole thing terribly confusing. What I normally do is
concatenate the code for the double quotes ("CHR(34)"). So, something like
the following might work (I removed all line continuations (" _"), but OE
may have wrapped the line...make sure to paste in as one line and add line
continuations where you like):



If Not i = 26 Then .Range("pfCell_" & i).Formula =
"=IF(OFFSET(clStart,pfDisc," & i & ")=0," & CHR(34) & CHR(34) &
",OFFSET(clStart,pfDisc," & i & "))"



HTH,

Conan






"Minitman" wrote in message
...
Greetings,

I found a solution to my copy and paste problem in the archives.

the problem is that I need to paste an empty cell as a choice in my IF
statement. Here is the formula in the cell called pfCell_1:

=IF(OFFSET(clStart,pfDisc,1)=0,"",OFFSET(clStart,p fDisc,1))

After I run the macro to overwrite the contents of the 79 named
ranges, this is what is returned in pfCell_1:

=IF(OFFSET(clStart,pfDisc,1)=0,,OFFSET(clStart,pfD isc,1))

Notice the missing "" marks.

Here is the macro that changes all 79 named ranges at one time:

Sub RecoverFormulas()
Dim i As Integer

With ActiveSheet
For i = 1 To 79
If Not i = 26 Then .Range("pfCell_" & i).Formula = _
"=IF(OFFSET(clStart,pfDisc," & i & _
")=0,,OFFSET(clStart,pfDisc," & i & "))"
Next i
End With

End Sub

When I tried to put "" between the ,,'s, debug kicked in and stopped
the macro with an error message - it did not like the ""'s !!!

How can This be rewritten so the I get empty named range if the result
is 0???

Any ideas, suggestions or thought on this matter?

Any help is appreciated.

-Minitman



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 293
Default Copy And Paste Macro Syntax Problem

The CHR(34) did the trick, thanks

-Minitman

On Wed, 26 Mar 2008 19:02:03 GMT, "Conan Kelly"
wrote:

Minitman,

You need to return double qotes inside of a string (a string is surrounded
by double quotes).

So when you insert 2 double quotes between the commas...well I'm not quite
sure what it is trying to do. To return double quotes inside a string, you
need to double, and sometimes triple or quadruple your double quotes,
depending on how many you need and where you need them. In your case, you
might try 4 quotes ("""").

But I find the whole thing terribly confusing. What I normally do is
concatenate the code for the double quotes ("CHR(34)"). So, something like
the following might work (I removed all line continuations (" _"), but OE
may have wrapped the line...make sure to paste in as one line and add line
continuations where you like):



If Not i = 26 Then .Range("pfCell_" & i).Formula =
"=IF(OFFSET(clStart,pfDisc," & i & ")=0," & CHR(34) & CHR(34) &
",OFFSET(clStart,pfDisc," & i & "))"



HTH,

Conan






"Minitman" wrote in message
.. .
Greetings,

I found a solution to my copy and paste problem in the archives.

the problem is that I need to paste an empty cell as a choice in my IF
statement. Here is the formula in the cell called pfCell_1:

=IF(OFFSET(clStart,pfDisc,1)=0,"",OFFSET(clStart,p fDisc,1))

After I run the macro to overwrite the contents of the 79 named
ranges, this is what is returned in pfCell_1:

=IF(OFFSET(clStart,pfDisc,1)=0,,OFFSET(clStart,pfD isc,1))

Notice the missing "" marks.

Here is the macro that changes all 79 named ranges at one time:

Sub RecoverFormulas()
Dim i As Integer

With ActiveSheet
For i = 1 To 79
If Not i = 26 Then .Range("pfCell_" & i).Formula = _
"=IF(OFFSET(clStart,pfDisc," & i & _
")=0,,OFFSET(clStart,pfDisc," & i & "))"
Next i
End With

End Sub

When I tried to put "" between the ,,'s, debug kicked in and stopped
the macro with an error message - it did not like the ""'s !!!

How can This be rewritten so the I get empty named range if the result
is 0???

Any ideas, suggestions or thought on this matter?

Any help is appreciated.

-Minitman



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
Copy and paste problem Germano Excel Discussion (Misc queries) 1 August 24th 07 12:45 PM
Copy/ Paste Problem DanielSP Setting up and Configuration of Excel 4 January 25th 07 02:42 AM
Copy/Paste Problem Seti Excel Worksheet Functions 0 August 31st 06 05:10 PM
Copy and Paste Problem Skc Excel Discussion (Misc queries) 1 March 8th 06 07:21 PM
Excel cut/Paste Problem: Year changes after data is copy and paste Asif Excel Discussion (Misc queries) 2 December 9th 05 05:16 PM


All times are GMT +1. The time now is 04:31 PM.

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

About Us

"It's about Microsoft Excel"