LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default How to copy only one value from range to worksheet

I have a worksheet called 'Exceptions' with data that I need to have applied
to multiple worksheets within the workbook based upon the value in A1
matching the value of B6 on the individual worksheets. This matching works,
but I need to have only the B column value on the 'Exceptions' sheet added to
each worksheet. The code below is copying the entire row of data (6 columns)
from the 'Exceptions' worksheet where the A1 value matches the B6 value on
the worksheets (which is what i initially wanted but now I need to strip
everything and only copy the one cell).

Can someone show me where I can make this change? Every time I do it, I get
different data sets added to my worksheets.



Sub Exceptions()

Dim r As Range, cell As Range, sh As Worksheet
Dim lastrow As Long
With Worksheets("Exceptions")
Set r = .Range(.Range("A1"), .Range("A1").End(xlDown))
End With
For Each cell In r
For Each sh In Worksheets
If LCase(sh.Name) < "exceptions" Then
If sh.Cells(6, "B").Value = cell Then

If Application.CountIf(sh.Columns(1), cell) 0 Then
lastrow = sh.Cells(Rows.Count, 1).End(xlUp).Row
cell.Resize(1, 6).Copy
sh.Cells(lastrow + 1, 1).PasteSpecial xlPasteValues
Else
cell.Resize(1, 6).Copy
sh.Range("A50").PasteSpecial xlPasteValues
End If
Exit For
End If
End If
Next
Next
End Sub

 
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
Worksheet range copy Graham H Excel Programming 3 July 4th 08 09:36 PM
copy range on every worksheet (diff names) to a master worksheet (to be created) Bernie[_2_] Excel Programming 2 September 22nd 04 03:30 PM
copy range on every worksheet (diff names) to a master worksheet (to be created) Bernie[_3_] Excel Programming 0 September 22nd 04 03:26 PM
Code to copy range vs Copy Entire Worksheet - can't figure it out Mike Taylor Excel Programming 1 April 15th 04 08:34 PM
How? Macro to copy range to new worksheet, name new worksheet, loop Repoman Excel Programming 9 October 9th 03 01:45 PM


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

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"