Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default my Franken-code

Hi,
I'm brand new to macros and coding in general. I've sifted through this
site for an answer, but there was no one post to cover what I needed, so I
pieced this baby together from different posts.

I will be getting these excel files frequently, and they can contain
thousands of rows. I need a macro that will search all rows and columns in
the active worksheet of any workbook I may choose, regardless of how many
rows it contains.

I need to replace each cell that contains only a single " mark with the
contents of the cell above it (somebody thinks it's a good idea to use ditto
marks in their database). There is legitimate use of quotes elsewhere in the
worksheet


Dim r As Range
Set r = ActiveSheet.UsedRange
r.Replace What:=""", Replacement:=MyCell.Value = ActiveCell.FormulaR1C1 =
"=R[-1]C", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End Sub


This will not run. But you could probably tell that from reading it, huh?
It says there's a syntax error, but I think it's more than that.

p.s.
I did read a post with a warning that worried me. I can't remember the exact
warning, but it was something about not using a whole worksheet as a range
because the code would remember the amount of rows used each time you ran it
and adjust the code to reflect that. The post said it was better to name a
specific range, but I want to be able to run this code no matter how many
rows.
Is that post true?

PLEASE HELP ME!
Thanx
jen
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default my Franken-code

Try the following:
Set r = ActiveSheet.UsedRange
For Each mycell In r
If mycell.Row 1 Then
ReplaceMe = Cells(mycell.Row - 1, mycell.Column).Value
mycell.Replace What:="""", Replacement:=ReplaceMe, LookAt:=xlWhole,
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
End If
Next mycell
End Sub

"justme" wrote:

Hi,
I'm brand new to macros and coding in general. I've sifted through this
site for an answer, but there was no one post to cover what I needed, so I
pieced this baby together from different posts.

I will be getting these excel files frequently, and they can contain
thousands of rows. I need a macro that will search all rows and columns in
the active worksheet of any workbook I may choose, regardless of how many
rows it contains.

I need to replace each cell that contains only a single " mark with the
contents of the cell above it (somebody thinks it's a good idea to use ditto
marks in their database). There is legitimate use of quotes elsewhere in the
worksheet


Dim r As Range
Set r = ActiveSheet.UsedRange
r.Replace What:=""", Replacement:=MyCell.Value = ActiveCell.FormulaR1C1 =
"=R[-1]C", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End Sub


This will not run. But you could probably tell that from reading it, huh?
It says there's a syntax error, but I think it's more than that.

p.s.
I did read a post with a warning that worried me. I can't remember the exact
warning, but it was something about not using a whole worksheet as a range
because the code would remember the amount of rows used each time you ran it
and adjust the code to reflect that. The post said it was better to name a
specific range, but I want to be able to run this code no matter how many
rows.
Is that post true?

PLEASE HELP ME!
Thanx
jen

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default my Franken-code


Okay,

I tried this and it partially works, though I don't know why, because I did
use 4 quote marks even though I think I should only need 3:


Sub Macro13()
'
' Macro13 Macro
' Macro recorded 12/5/2006 by jeny
'
' Keyboard Shortcut: Ctrl+q
'
Do
Cells.Select
Range("A63").Activate
Selection.Find(What:="""", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.FormulaR1C1 = "=R[-1]C"
Loop
End Sub


It seems to replace single quotes, but I get this error:
"Run-time error '91': Object Variable or With Block variable not set"
Also, the shortcut doesn't work.

??

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default my Franken-code

It also removes legitimate quotes around words!
and if I use it more than a few times it stop working. :(

PLEASE help give life to my Frankencode!
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default my Franken-code

Thanx for the explanations,
That was driving me crazy!

You are an angel

;)

jeny

"Neily" wrote:

I think the quote mark issue is because if you put quotemarks inside a set of
quotemarks, you have to double them up. Hence the double quote in the middle
is the representation of a single ".

ie It you write code to put a formula into a cell it goes like this...
ActiveCell.Formula="=TEXT(NOW(),""dd-mmm-yyyy"")"

When you run this, it converts the double "s into singles on the worksheet.

"justme" wrote:


Okay,

I tried this and it partially works, though I don't know why, because I did
use 4 quote marks even though I think I should only need 3:


Sub Macro13()
'
' Macro13 Macro
' Macro recorded 12/5/2006 by jeny
'
' Keyboard Shortcut: Ctrl+q
'
Do
Cells.Select
Range("A63").Activate
Selection.Find(What:="""", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.FormulaR1C1 = "=R[-1]C"
Loop
End Sub


It seems to replace single quotes, but I get this error:
"Run-time error '91': Object Variable or With Block variable not set"
Also, the shortcut doesn't work.

??



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default my Franken-code

no probs - happy to help :)

"justme" wrote:

WOOOWWW!
Ok, Marion,
That was WAY TOO COOL!

I pasted your second code over my current macro and it was like a symphony,
watching the wave of quotes change to dates all the way down!!

Please note that all those other little notes about the code not working
were in reference to my second post where I posted another attempt of my own.


You are truly amazing, and i thank you for your time and caring ;.(
(tears),
and *magic* code, as opposed to my mad Frankencode!

jeny
OOO

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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
Modification in the CODE to HIDE rows and columns that start with ZERO (code given) Thulasiram[_2_] Excel Programming 4 September 26th 06 04:15 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM


All times are GMT +1. The time now is 12:50 AM.

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"