Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 193
Default Don't Replace existing Cell

I am having trouble getting this to work. I have a list of customers some
with specific notes assigned to them and some without. What I want to do is
be able to run this macro that compares the two lists and inserts the notes
as required, but I do not want the existing notes in the master list to be
affected or changed.

This is my macro that copies over the notes from one sheet to the master.

Sub Add_Notes_To_Master()

Range("C5:C500").Select
ActiveWorkbook.Names.Add Name:="Sorted", RefersToR1C1:= _
"='Sales By State'!R5C3:R500C3"
Sheets("CrosstabSales2_US$_RegionSalesR").Select
Range("F2:F696").Select
ActiveWorkbook.Names.Add Name:="Active_Accounts", RefersToR1C1:= _
"='CrosstabSales2_US$_RegionSalesR'!R2C6:R696C 6"

Set MyFirstRange = Range("Active_Accounts")
Set MySecondRange = Range("Sorted")
fnd = 0

For Each C In MyFirstRange
For Each n In MySecondRange
If C.Value = n.Value Then
C.Offset(0, 19).Value = n.Offset(0, 4).Value
fnd = 1
End If
Next
Next
Range("B2").Select
End Sub

I can't seam to figure out the VBA to tell the above to ignore the customers
cells with notes already inputted in them.
--
Pete
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Don't Replace existing Cell

Add another IF statement to check if the destination cell in MySecondRange is
blank or not before preceding. For example,
For Each n In MySecondRange
If C.Value = n.Value Then
C.Offset(0, 19).Value = n.Offset(0, 4).Value
fnd = 1
End If
Next


----------
Thanks,
Anony


"Pete" wrote:

I am having trouble getting this to work. I have a list of customers some
with specific notes assigned to them and some without. What I want to do is
be able to run this macro that compares the two lists and inserts the notes
as required, but I do not want the existing notes in the master list to be
affected or changed.

This is my macro that copies over the notes from one sheet to the master.

Sub Add_Notes_To_Master()

Range("C5:C500").Select
ActiveWorkbook.Names.Add Name:="Sorted", RefersToR1C1:= _
"='Sales By State'!R5C3:R500C3"
Sheets("CrosstabSales2_US$_RegionSalesR").Select
Range("F2:F696").Select
ActiveWorkbook.Names.Add Name:="Active_Accounts", RefersToR1C1:= _
"='CrosstabSales2_US$_RegionSalesR'!R2C6:R696C 6"

Set MyFirstRange = Range("Active_Accounts")
Set MySecondRange = Range("Sorted")
fnd = 0

For Each C In MyFirstRange
For Each n In MySecondRange
If C.Value = n.Value Then
C.Offset(0, 19).Value = n.Offset(0, 4).Value
fnd = 1
End If
Next
Next
Range("B2").Select
End Sub

I can't seam to figure out the VBA to tell the above to ignore the customers
cells with notes already inputted in them.
--
Pete

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Ignore Previous Post

Seemed to pressed enter by accident last time. This is the correct post.

Add another IF statement to check if the destination cell in MySecondRange
is blank or not before proceeding. For example,
For Each n In MySecondRange
If C.Value = n.Value Then
If n.Offset(0,4).Value = "" Then
C.Offset(0, 19).Value = n.Offset(0, 4).Value
fnd = 1
End If
End If
Next

----------
Cheers,
Anony


"Pete" wrote:

I am having trouble getting this to work. I have a list of customers some
with specific notes assigned to them and some without. What I want to do is
be able to run this macro that compares the two lists and inserts the notes
as required, but I do not want the existing notes in the master list to be
affected or changed.

This is my macro that copies over the notes from one sheet to the master.

Sub Add_Notes_To_Master()

Range("C5:C500").Select
ActiveWorkbook.Names.Add Name:="Sorted", RefersToR1C1:= _
"='Sales By State'!R5C3:R500C3"
Sheets("CrosstabSales2_US$_RegionSalesR").Select
Range("F2:F696").Select
ActiveWorkbook.Names.Add Name:="Active_Accounts", RefersToR1C1:= _
"='CrosstabSales2_US$_RegionSalesR'!R2C6:R696C 6"

Set MyFirstRange = Range("Active_Accounts")
Set MySecondRange = Range("Sorted")
fnd = 0

For Each C In MyFirstRange
For Each n In MySecondRange
If C.Value = n.Value Then
C.Offset(0, 19).Value = n.Offset(0, 4).Value
fnd = 1
End If
Next
Next
Range("B2").Select
End Sub

I can't seam to figure out the VBA to tell the above to ignore the customers
cells with notes already inputted in them.
--
Pete

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
Replace Existing File Lynn Excel Programming 5 August 26th 06 06:30 PM
Replace an Existing File Jim Skrydlak Excel Programming 2 August 8th 06 09:52 PM
How do I paste to append instead of replace existing data? Joel Thomas Excel Discussion (Misc queries) 1 October 3rd 05 01:32 PM
Do you want to replace existing file? Tony Excel Programming 3 July 15th 04 11:21 PM
Automatically replace existing file on save ronber[_2_] Excel Programming 1 September 25th 03 10:05 PM


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