View Single Post
  #15   Report Post  
Posted to microsoft.public.excel.programming
Greg Wilson[_4_] Greg Wilson[_4_] is offline
external usenet poster
 
Posts: 218
Default Maybe this isn't possible to match name and copy?

Annette,

I'm at a loss at this point. I'm willing to have a look
at it if you email the workbook. Make sure the VBE and
worksheets are all unprotected. As I said in my first
post, I'm just a VBA amateur. I also work for a living
and have yet to start on my income tax which is due the
end of the month. So no promises.

None the less, at least normally, this should be easy. I
suspect at this point it has to do with how the sheets are
added to the workbook or a sheet referencing issue; i.e.
Sheet1 is not necessarily the same as Sheets("Sheet1").

Greg Wilson



-----Original Message-----
I was using the first one ... and when I changed the

numbers, it would run
more sheets.

When I use this (second and what you want me to test)

against your example,
nothing happens. I recopied the code into a new name so

I had the same code
and checked the names you provided. The second code runs

but there are no
changes.

Thanks again for staying with this ... I am pretty sure

what you have here
is what I need.

"Greg Wilson" wrote

in message
...
Annette,

The code below was the second code offering and is the

one
that I suggested you use. This should definately go

past
Sheet4 assuming you have more than 4 sheets. The first
(longer code) should only go to Sheet4 - it is designed

to
do this. Tom Ogilvy's comment confirmed this. Are you
saying that this code only goes to Sheet4 ??? Also, the
code below won't do anything unless it finds a match in
Cell A1 of each sheet. Are you sure the names are in

Cell
A1 of each sheet ???

My first code offering was designed to look anywhere in
the used range of each sheet instead of just Cell A1.
Therefore, it could find a match if the name was not in
A1. That is why I suspect you had some success with

that
code. That code also has a flaw I am aware of. I won't
bother to fix it unless we end up using it.

Please confirm if you were using the code below and if

the
names are in Cell A1 of each sheet (except Sheet1).

Dim MainSheet As Worksheet
Dim Rng As Range, C As Range, CC As Range
Dim i As Integer
Dim ShtCount As Integer

Set MainSheet = Sheets(1)
ShtCount = ThisWorkbook.Sheets.Count
Set Rng = MainSheet.Columns(1). _
SpecialCells(xlCellTypeConstants)
For Each C In Rng.Cells
For i = 2 To ShtCount
Set CC = Sheets(i).Range("A1")
If Trim(C) = Trim(CC) Then
CC.Offset(1).Rows.Insert Shift:=xlDown
CC.Offset(1) = C.Offset(, 1)
End If
Next
Next
End Sub

Regards,
Greg

-----Original Message-----
Okay, now this is just getting strange. I copied

everything verbatim as you
instructed and thought if this worked ... I could

rework
the code that comes
before this. Well, needless to say ... the second code

that you indicated
for me to use along with the sample provided for layout

refused to run past
sheet 4 ... this is just too bizarre. Obviously

something is wrong here ...
I copied the code again and even closed Excel to be

sure ... I'm using Excel
2000/with Win2000.

I didn't even monkey with the code .. it is exactly as

you wrote it and it
refuses to go past sheet4. If you had your sample

working .. .maybe it is
this notebook I'm using ... it's a .. neva mind ..

doubt
it is that (just
getting frustrated!). There something I'm missing

here!

Yours did run past sheet4 .. yes? And you didn't change

anything in the code
from your original post? I wonder why mine won't work

like yours ... and
the list on sheet1 is not even in alpha order (mine is

going to be in the
final working code).

Thanks again for not giving up.


.



.