Previously working VBA code acting differently. Copying, getting popup "name already exists"

Kaldric

New Member
Joined
Sep 9, 2014
Messages
13
I have this code that will look for a match of a value in a specific cell in column G and copy that row to another worksheet. It was working fine (except that I want to restrict the copied cells to a set number of rows rather than the entire row, but that is a different issue, and not very important at this point), but I suddenly started getting a window popping up every time I ran the code: "The name 'COSTCODES' already exists. Click Yes to use that version of the name, or click No to rename the version of 'COSTCODES' you're moving or copying." I have to click Yes for every row that the code copies over. For now, this only requires 5 clicks, but I am only testing it on a small portion of the final file and I don't want to have to click 1000 times just to step through the program.

Here is the code I am using:

Sub CopyxSM() Dim RngColF As Range
Dim i As Range
Dim Dest As Range




Set Dest = Sheets("SOLAR MATERIALS - SM").Range("A7")




With Sheets("MASTER PO LOG")
.Select
Set RngColF = .Range("G1", .Range("G" & .Rows.Count).End(xlUp))




For Each i In RngColF
Select Case i.Value
Case "SM-01", "SM-02", "SM-03", "SM-04", "SM-05"
i.EntireRow.Copy Dest
Set Dest = Dest.Offset(1)
Case Else
'do nothing
End Select
Next i
End With
End Sub

If anyone can help, I would appreciate it.

Thanks in advance.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
While I haven't found a solution yet, I was able to eliminate the need to respond to each popup by inserting this code:


<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">Application.DisplayAlerts = False
</code></pre>
 
Upvote 0

Forum statistics

Threads
1,216,123
Messages
6,128,975
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top