Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Corrupted Macro


The answer to a question I asked some time ago was a macro which worked
beautifully for a
while; but it apparently has been corrupted. I cannot get in touch with the
person who provided
it. I dont understand Visual Basic so need help.

The purpose of the macro is to copy formulas from all the cells in the row 1
and enter them inrow 2 with a new file name.

As a sample, one of the formulas for customer Jones is: (many of the
formulas are far more complex)
='\\Server1\shareddocs\Daily 2005\[Jones.xls]BPR'!$D$2&
""&LEFT('\\Server1\shareddocs\Daily 2005\[Jones.xls]BPR'!$A$1,9)

The macro asks for a customer name to be used in the formulas in the next
row (say €śSmith€ť) and
then replaces Jones with Smith in each formula.

Apparently the name which corrupted the macro was (there was a previous
customer named
Garcia, so the next Garcia was dealt with as) Garcia.Lettie. It was handled
correctly; but
when I entered the next name (say) Smith, I got Smith.Lettie. So I replaced
Garcia.Lettie with
GarciaL. The name on the next line, Smith, was copied as SmithL. Im sure
there is some logic
to the corruption but I cant fathom what it might be.

The macro is as follows:

Sub AddLineData() ' to add a row on data page
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Newname = InputBox("Enter New Name")
lr = Cells(Rows.Count, "g").End(xlUp).Row + 1
Rows(lr - 1).Copy Rows(lr)
mcel = Cells(lr - 1, "f")
mn = Trim(Right(mcel, Len(mcel) - InStr(mcel, " ") + 1))
Rows(lr).Replace What:=mn, Replacement:=Newname, LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Sub AddLineSummary() ' to add a row on summary page
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Newname = InputBox("Enter New Name")
lr = Cells(Rows.Count, "g").End(xlUp).Row + 1
Rows(lr - 1).Copy Rows(lr)
mn = Cells(lr - 1, 2)
Cells(lr, 2).Replace What:=mn, Replacement:=Newname


Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

I would appreciate any help you can offer.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Corrupted Macro

The first macro was not written to handle names with spaces in them.
Presumably the client name is in column F in the row above. The macro gets
that name, then pulls out everything to the right of the first space as the
text to be replaced. So, for the first macro, if you have Lettie Garcia in
column F, only "Garcia" will be replaced; it it's L Smith, only the "Smith"
will be replaced.

But this doesn't match what you give as examples: you say Garcia.Lettie, not
Lettie Garcia.

If you are having the same problem with the 2nd macro, this also doesn't
explain it, as it retrieves all information from column B as the name to be
replaced.

Please post back with EXACTLY what text is found in column F on the data page
and column B of the summary page.

On Sun, 30 Jan 2005 06:51:02 -0800, VJ7777
wrote:


The answer to a question I asked some time ago was a macro which worked
beautifully for a
while; but it apparently has been corrupted. I cannot get in touch with the
person who provided
it. I don’t understand Visual Basic so need help.

The purpose of the macro is to copy formulas from all the cells in the row 1
and enter them inrow 2 with a new file name.

As a sample, one of the formulas for customer Jones is: (many of the
formulas are far more complex)
='\\Server1\shareddocs\Daily 2005\[Jones.xls]BPR'!$D$2&
""&LEFT('\\Server1\shareddocs\Daily 2005\[Jones.xls]BPR'!$A$1,9)

The macro asks for a customer name to be used in the formulas in the next
row (say “Smith”) and
then replaces Jones with Smith in each formula.

Apparently the name which corrupted the macro was (there was a previous
customer named
Garcia, so the next Garcia was dealt with as) Garcia.Lettie. It was handled
correctly; but
when I entered the next name (say) Smith, I got Smith.Lettie. So I replaced
Garcia.Lettie with
GarciaL. The name on the next line, Smith, was copied as SmithL. I’m sure
there is some logic
to the corruption but I can’t fathom what it might be.

The macro is as follows:

Sub AddLineData() ' to add a row on data page
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Newname = InputBox("Enter New Name")
lr = Cells(Rows.Count, "g").End(xlUp).Row + 1
Rows(lr - 1).Copy Rows(lr)
mcel = Cells(lr - 1, "f")
mn = Trim(Right(mcel, Len(mcel) - InStr(mcel, " ") + 1))
Rows(lr).Replace What:=mn, Replacement:=Newname, LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Sub AddLineSummary() ' to add a row on summary page
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Newname = InputBox("Enter New Name")
lr = Cells(Rows.Count, "g").End(xlUp).Row + 1
Rows(lr - 1).Copy Rows(lr)
mn = Cells(lr - 1, 2)
Cells(lr, 2).Replace What:=mn, Replacement:=Newname


Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

I would appreciate any help you can offer.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Corrupted Macro



"Myrna Larson" wrote:

The first macro was not written to handle names with spaces in them.
Presumably the client name is in column F in the row above. The macro gets
that name, then pulls out everything to the right of the first space as the
text to be replaced. So, for the first macro, if you have Lettie Garcia in
column F, only "Garcia" will be replaced; it it's L Smith, only the "Smith"
will be replaced.

But this doesn't match what you give as examples: you say Garcia.Lettie, not
Lettie Garcia.

If you are having the same problem with the 2nd macro, this also doesn't
explain it, as it retrieves all information from column B as the name to be
replaced.

Please post back with EXACTLY what text is found in column F on the data page
and column B of the summary page.

On Sun, 30 Jan 2005 06:51:02 -0800, VJ7777
wrote:


The answer to a question I asked some time ago was a macro which worked
beautifully for a
while; but it apparently has been corrupted. I cannot get in touch with the
person who provided
it. I dont understand Visual Basic so need help.

The purpose of the macro is to copy formulas from all the cells in the row 1
and enter them inrow 2 with a new file name.

As a sample, one of the formulas for customer Jones is: (many of the
formulas are far more complex)
='\\Server1\shareddocs\Daily 2005\[Jones.xls]BPR'!$D$2&
""&LEFT('\\Server1\shareddocs\Daily 2005\[Jones.xls]BPR'!$A$1,9)

The macro asks for a customer name to be used in the formulas in the next
row (say €śSmith€ť) and
then replaces Jones with Smith in each formula.

Apparently the name which corrupted the macro was (there was a previous
customer named
Garcia, so the next Garcia was dealt with as) Garcia.Lettie. It was handled
correctly; but
when I entered the next name (say) Smith, I got Smith.Lettie. So I replaced
Garcia.Lettie with
GarciaL. The name on the next line, Smith, was copied as SmithL. Im sure
there is some logic
to the corruption but I cant fathom what it might be.

The macro is as follows:

Sub AddLineData() ' to add a row on data page
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Newname = InputBox("Enter New Name")
lr = Cells(Rows.Count, "g").End(xlUp).Row + 1
Rows(lr - 1).Copy Rows(lr)
mcel = Cells(lr - 1, "f")
mn = Trim(Right(mcel, Len(mcel) - InStr(mcel, " ") + 1))
Rows(lr).Replace What:=mn, Replacement:=Newname, LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Sub AddLineSummary() ' to add a row on summary page
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Newname = InputBox("Enter New Name")
lr = Cells(Rows.Count, "g").End(xlUp).Row + 1
Rows(lr - 1).Copy Rows(lr)
mn = Cells(lr - 1, 2)
Cells(lr, 2).Replace What:=mn, Replacement:=Newname


Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

I would appreciate any help you can offer.


Hi Myrna:

I have never replied to a post so hope this gets to you. I understand what you are saying and originally thought the problem was a space or something like your comment. However the example I gave of Garcia.Lettie; then GarciaL, is really what happened. I tried fool it by going back to the very first row and deleting subsequent rows. At that point, it handled a different name (say Prieto) on row 2 OK but no matter what name I entered from that point on it continued to repeat Prieto in rows 3 and 4.


The formula in Column F is:
'\\Server1\Daily 2005\[Garcial.xls]BPR'!$D$2&" "&LEFT('\\Server1\Daily
2005\[Garcial.xls]BPR'!$A$1,9)

NOTE: For some weird reason I cannot copy the formula from the file which
is on a remote computer and paste it in this post. I copy from the remote
computer and paste locally all the time. This is why I think something
strange is going on with the macro.

But, you asked for the TEXT in Column B. It is "6 Garcia" which is the
correct info from two cells in the file.

After entering the name "Hill" on the next line here is the result in Column
F:
'\\Server1\Daily 2005\[Hilll.xls]BPR'!$D$2&" "&LEFT('\\Server1\Daily
2005\[Hilll.xls]BPR'!$A$1,9)

See the extra "l" which was added to Hill.

The formula in Column B of the Summary page is:
There is no formula here; it is the name of a salesperson. Nothing on the
Summary page appears to be related to the formulas on the Data page - the
Summary page merely accumulates vaious totals by salesperson.

If you provide an email address I will be happy to provide you with the
report and a couple of sample customer files.

I really appreciate your interest and willingness to help me.

Vince

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Corrupted Macro



"VJ7777" wrote:



"Myrna Larson" wrote:

The first macro was not written to handle names with spaces in them.
Presumably the client name is in column F in the row above. The macro gets
that name, then pulls out everything to the right of the first space as the
text to be replaced. So, for the first macro, if you have Lettie Garcia in
column F, only "Garcia" will be replaced; it it's L Smith, only the "Smith"
will be replaced.

But this doesn't match what you give as examples: you say Garcia.Lettie, not
Lettie Garcia.

If you are having the same problem with the 2nd macro, this also doesn't
explain it, as it retrieves all information from column B as the name to be
replaced.

Please post back with EXACTLY what text is found in column F on the data page
and column B of the summary page.

On Sun, 30 Jan 2005 06:51:02 -0800, VJ7777
wrote:


The answer to a question I asked some time ago was a macro which worked
beautifully for a
while; but it apparently has been corrupted. I cannot get in touch with the
person who provided
it. I dont understand Visual Basic so need help.

The purpose of the macro is to copy formulas from all the cells in the row 1
and enter them inrow 2 with a new file name.

As a sample, one of the formulas for customer Jones is: (many of the
formulas are far more complex)
='\\Server1\shareddocs\Daily 2005\[Jones.xls]BPR'!$D$2&
""&LEFT('\\Server1\shareddocs\Daily 2005\[Jones.xls]BPR'!$A$1,9)

The macro asks for a customer name to be used in the formulas in the next
row (say €śSmith€ť) and
then replaces Jones with Smith in each formula.

Apparently the name which corrupted the macro was (there was a previous
customer named
Garcia, so the next Garcia was dealt with as) Garcia.Lettie. It was handled
correctly; but
when I entered the next name (say) Smith, I got Smith.Lettie. So I replaced
Garcia.Lettie with
GarciaL. The name on the next line, Smith, was copied as SmithL. Im sure
there is some logic
to the corruption but I cant fathom what it might be.

The macro is as follows:

Sub AddLineData() ' to add a row on data page
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Newname = InputBox("Enter New Name")
lr = Cells(Rows.Count, "g").End(xlUp).Row + 1
Rows(lr - 1).Copy Rows(lr)
mcel = Cells(lr - 1, "f")
mn = Trim(Right(mcel, Len(mcel) - InStr(mcel, " ") + 1))
Rows(lr).Replace What:=mn, Replacement:=Newname, LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Sub AddLineSummary() ' to add a row on summary page
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Newname = InputBox("Enter New Name")
lr = Cells(Rows.Count, "g").End(xlUp).Row + 1
Rows(lr - 1).Copy Rows(lr)
mn = Cells(lr - 1, 2)
Cells(lr, 2).Replace What:=mn, Replacement:=Newname


Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

I would appreciate any help you can offer.


Hi Myrna:

I have never replied to a post so hope this gets to you. I understand what you are saying and originally thought the problem was a space or something like your comment. However the example I gave of Garcia.Lettie; then GarciaL, is really what happened. I tried fool it by going back to the very first row and deleting subsequent rows. At that point, it handled a different name (say Prieto) on row 2 OK but no matter what name I entered from that point on it continued to repeat Prieto in rows 3 and 4.


The formula in Column F is:
'\\Server1\Daily 2005\[Garcial.xls]BPR'!$D$2&" "&LEFT('\\Server1\Daily
2005\[Garcial.xls]BPR'!$A$1,9)

NOTE: For some weird reason I cannot copy the formula from the file which
is on a remote computer and paste it in this post. I copy from the remote
computer and paste locally all the time. This is why I think something
strange is going on with the macro.

But, you asked for the TEXT in Column B. It is "6 Garcia" which is the
correct info from two cells in the file.

After entering the name "Hill" on the next line here is the result in Column
F:
'\\Server1\Daily 2005\[Hilll.xls]BPR'!$D$2&" "&LEFT('\\Server1\Daily
2005\[Hilll.xls]BPR'!$A$1,9)

See the extra "l" which was added to Hill.

The formula in Column B of the Summary page is:
There is no formula here; it is the name of a salesperson. Nothing on the
Summary page appears to be related to the formulas on the Data page - the
Summary page merely accumulates vaious totals by salesperson.

If you provide an email address I will be happy to provide you with the
report and a couple of sample customer files.

I really appreciate your interest and willingness to help me.

Vince
Hi Myrna:

I have continued to play with this report and it appears that the problem is
caused by one of two factors: 1. Where there is more than one capital
letter in the name; and/or 2. Where the file name is different from the name
that prints in Column F.
Hope this helps.
Vince
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Corrupted Macro

On Mon, 31 Jan 2005 16:11:02 -0800, VJ7777
wrote:

2. Where the file name is different from the name that prints in Column F.


That is the problem exactly. The macro assumes that the file name can be
determined from the TEXT (i.e. the formula result, not the formula itself) in
column F. The text there is just Garcia, but the file name is Garcial. The
macro says to look at the formula and replace the letters "Garcia" with
"Hill". And that's what it does. So "GarciaL" becomes "HillL".

You have to get things back into sync so that the name which is used as part
of the file name is the same as what is in columns F and B.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Corrupted Macro



"Myrna Larson" wrote:

On Mon, 31 Jan 2005 16:11:02 -0800, VJ7777
wrote:

2. Where the file name is different from the name that prints in Column F.


That is the problem exactly. The macro assumes that the file name can be
determined from the TEXT (i.e. the formula result, not the formula itself) in
column F. The text there is just Garcia, but the file name is Garcial. The
macro says to look at the formula and replace the letters "Garcia" with
"Hill". And that's what it does. So "GarciaL" becomes "HillL".

You have to get things back into sync so that the name which is used as part
of the file name is the same as what is in columns F and B.

Is there any way to change the macro to deal with the typed name only? The customer last name in Column F is the actual name in the customer record. If multiple customers have the same last name the file names must be modified.

Again, I really appreciate your help.
Vince
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Corrupted Macro

The fundamental problem is that when the macro was written, the 2
specifications were that (1) the person's last name could be found to the
right of the 1st space in the text in column F on the 1st sheet, and in column
B on the 2nd sheet, and (2) the workbook name consisted of that last name
followed immediately by ".xls"

Then you hit a problem: that naming scheme can no longer work because you have
two people with the same last name. When that occurred, (1) the file was
created and named "GarciaL.xls" (you haven't said how the name is assigned).
(2) But in the workbook, BPR!A1 gives the last name, Garcia, not the filename
GarciaL.

So the macro can no longer work because the 2nd assumption -- that the file
name is always the last name + .xls -- has been violated. It sounds like you
need TWO cells on the worksheet, one containing the client's name, the other
the base file name.

If you set up a 2nd cell for the file name, then you would need to do that for
*all* existing workbooks. Then you have to change the formula in column F to
look at the cell containing the file name instead of cell $A$1. The 2nd macro
has to be changed to look for the file name not in column B, but in a new
column.

BTW, you *DO* need to resolve the underlying problem here. You could just
manually fix the worksheet names in the formulas in the rows below the Garcia
row. But the problem will recur when (a) you have another duplicate client
name, or (b) you try to insert a new client after Garcia.

the example I gave of Garcia.Lettie; then GarciaL, is really what happened.
The formula in Column F is:
...&" "&LEFT('\\Server1\Daily 2005\[Garcial.xls]BPR'!$A$1,9)


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Corrupted Macro



"Myrna Larson" wrote:

The fundamental problem is that when the macro was written, the 2
specifications were that (1) the person's last name could be found to the
right of the 1st space in the text in column F on the 1st sheet, and in column
B on the 2nd sheet, and (2) the workbook name consisted of that last name
followed immediately by ".xls"

Then you hit a problem: that naming scheme can no longer work because you have
two people with the same last name. When that occurred, (1) the file was
created and named "GarciaL.xls" (you haven't said how the name is assigned).
(2) But in the workbook, BPR!A1 gives the last name, Garcia, not the filename
GarciaL.

So the macro can no longer work because the 2nd assumption -- that the file
name is always the last name + .xls -- has been violated. It sounds like you
need TWO cells on the worksheet, one containing the client's name, the other
the base file name.

If you set up a 2nd cell for the file name, then you would need to do that for
*all* existing workbooks. Then you have to change the formula in column F to
look at the cell containing the file name instead of cell $A$1. The 2nd macro
has to be changed to look for the file name not in column B, but in a new
column.

BTW, you *DO* need to resolve the underlying problem here. You could just
manually fix the worksheet names in the formulas in the rows below the Garcia
row. But the problem will recur when (a) you have another duplicate client
name, or (b) you try to insert a new client after Garcia.

the example I gave of Garcia.Lettie; then GarciaL, is really what happened.
The formula in Column F is:
...&" "&LEFT('\\Server1\Daily 2005\[Garcial.xls]BPR'!$A$1,9)


Hi, Myrna:

Can you tell me what I am doing wrong in dealing with this discussion group.
I can't seem to get in sync with your replies. I keep checking the "notify
me of replies box" but never get notified and twice Microsoft has a problem
with my input so it loses it.

But, back to the macro, I did not specify that the file name must be the
same as the customer name. That was an assumption of the person who wrote
the macro. Quite simply, all I want to do is change the file name used in
the formulae on the previous row to the file name entered in the Name box.
Again, thank you for your continued assistance.
Vince
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Corrupted Macro

If you follow your new plan, to put the base FILENAME in column A, the
following macro should work for either the data sheet OR the summary sheet. In
the problem case that started all of this, the client name is Garcia, but the
name in column A would be the file name, GarciaL.

The macro just finds the last name in column A and saves it in a variable.
Then it copies the entire next-to-last row to the last row. Then it replaces
the OldName with the NewName that was saved before the copy.


Sub AddLineData() ' to add a row on data page OR summary page
Dim lr As Long
Dim NewName As String
Dim OldName As String
Application.DisplayAlerts = False
Application.ScreenUpdating = False

'the new name must already have been entered in column A
'of the last row, but the rest of the row is blank

lr = Cells(Rows.Count, "A").End(xlUp).Row
NewName = Cells(lr, 1).Value 'save this because copy will wipe it out

'next line overwrites the new name, but it doesn't matter
'because we saved it above
Rows(lr - 1).Copy Rows(lr)

'replace the old name with the new name
OldName = Cells(lr - 1, 1).Value
Rows(lr).Replace What:=OldName, Replacement:=Newname, LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False

Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Corrupted Macro



"Myrna Larson" wrote:

If you follow your new plan, to put the base FILENAME in column A, the
following macro should work for either the data sheet OR the summary sheet. In
the problem case that started all of this, the client name is Garcia, but the
name in column A would be the file name, GarciaL.

The macro just finds the last name in column A and saves it in a variable.
Then it copies the entire next-to-last row to the last row. Then it replaces
the OldName with the NewName that was saved before the copy.


Sub AddLineData() ' to add a row on data page OR summary page
Dim lr As Long
Dim NewName As String
Dim OldName As String
Application.DisplayAlerts = False
Application.ScreenUpdating = False

'the new name must already have been entered in column A
'of the last row, but the rest of the row is blank

lr = Cells(Rows.Count, "A").End(xlUp).Row
NewName = Cells(lr, 1).Value 'save this because copy will wipe it out

'next line overwrites the new name, but it doesn't matter
'because we saved it above
Rows(lr - 1).Copy Rows(lr)

'replace the old name with the new name
OldName = Cells(lr - 1, 1).Value
Rows(lr).Replace What:=OldName, Replacement:=Newname, LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False

Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Thank you! Thank you!! Thank you!!! It works beautifully. To stretch my luck, could you give me a modification of this macro which looks for (begins with) the name in A6 and continues copying as long as there is a name in Column A. This way I could copy and paste a list of names into Column A5 through A whatever. Then I could write formulas in Row 5 from B5 to whatever. Then hit the "name" button to begin and the macro would copy beginning at Row 6 until the end of names in Column A.

I really appreciate this. It is the next-to-final step in what I consider
to be a great system for manufactured home dealerships. There is one more
thing I need. If you aren't sorry you offered to help me by now, perhaps I
could ask one more thing after this one.
Thanks again,
Vince


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Corrupted Macro

The following looks for the last name entered in column A, and the last
formula entered in column B. Then if fills the formulas down through all of
the rows that have names. Then it goes through the newly filled rows,
replacing the name that was used in the last formula row with the name that's
in column A of the current row.

As far as more macros are concerned, here's my reaction. Since you are
"designing" a business system, I think it's imperative that YOU understand how
the macros work and are able to modify or fix them if needed and how to write
more code for other tasks. Maybe this would be a good point for you to start
on that aspect of it. Otherwise, since this is a business application, you
probably should hire an Excel consultant who will guarantee his work.

Option Explicit

Sub CopyFormulasDown()
Dim LastFormulaRow As Long
Dim LastNameRow As Long
Dim OldName As String
Dim R As Long

With ActiveSheet
'find last row with a formula -- use column B
LastFormulaRow = .Cells(.Rows.Count, 2).End(xlUp).Row
'find last row with a name -- column A
LastNameRow = .Cells(.Rows.Count, 1).End(xlUp).Row
'if there are no rows without formulas, quit
If LastNameRow <= LastFormulaRow Then Exit Sub

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

'fill the formulas down
.Cells(LastFormulaRow, 2) _
.Resize(LastNameRow - LastFormulaRow + 1, 254).FillDown

'get the old name used in those formulas from column A
OldName = .Cells(LastFormulaRow, 1).Value

'go through all rows that were without formulas, replacing that
'old name with what's in column A of the current row
For R = LastFormulaRow + 1 To LastNameRow
.Rows(R).Replace what:=OldName, Replacement:=.Cells(R, 1).Value, _
LookAt:=xlPart, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
Next R

'recalculate the sheet
.Calculate

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End With
End Sub

On Tue, 1 Feb 2005 06:39:09 -0800, VJ7777
wrote:


Thank you! Thank you!! Thank you!!! It works beautifully. To stretch my

luck, could you give me a modification of this macro which looks for (begins
with) the name in A6 and continues copying as long as there is a name in
Column A. This way I could copy and paste a list of names into Column A5
through A whatever. Then I could write formulas in Row 5 from B5 to whatever.
Then hit the "name" button to begin and the macro would copy beginning at Row
6 until the end of names in Column A.
I really appreciate this. It is the next-to-final step in what I consider
to be a great system for manufactured home dealerships. There is one more
thing I need. If you aren't sorry you offered to help me by now, perhaps I
could ask one more thing after this one.
Thanks again,
Vince


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
Is my file corrupted? Kevin Excel Discussion (Misc queries) 3 March 16th 10 01:28 PM
Import from SAP corrupted JJSEE New Users to Excel 1 August 11th 09 09:46 PM
Corrupted file poul, denmark Excel Discussion (Misc queries) 2 April 24th 05 08:07 PM
Corrupted File trini Excel Discussion (Misc queries) 0 March 12th 05 02:07 AM
VBA --- Corrupted xls file Jag Man Excel Programming 4 January 3rd 04 07:35 PM


All times are GMT +1. The time now is 06:13 AM.

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"