Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default Please help really need this to work

have a spread sheet with column A and B being static but Column C1 has a
value 101 and D has 102 and so on till 900. What I want to do is that compare
C1 with another sheet that is in same format but missing number in between
for example its has C1=101 and D1=103. If C101 is there i need to copy all
value in that column to sheet 2 underneath C101 but if D1 is 103 then it
should put 0' in D1=102 from D2 - D25. let me know if there can be any macro
written to compare and copy the values.

If you dont understand anypart please feel free to ask as many questions

Your help will be life saver.

Regards

Arain


Joel wrote this code but its not working please let me know if you can fix it.


To explain in detail. The first sheet looks like this

c d e
101 103 104
2256 2223 3345

sheet 2 looks like this

C D E F
101 102 103 104

Now i want to check if 101 exist in sheet 1 copy all values underneath that
column to sheet 2 till C25

If 102 does not exist replace the cell with D25

if 103 exist copy all value undernead 103 to sheet 2 and so on.

Sub copycells()
Const FirstSheet = "sheet1"
Const SecondSheet = "sheet2"


Sheets(FirstSheet).Activate
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column

Set HeaderRange = Range(Cells(1, "C"), Cells(1, LastColumn))

For Each cell In HeaderRange

If cell = Sheets(SecondSheet).Cells(cell.Row, cell.Column) Then

Sheets(FirstSheet).Activate
LastRow = Cells(Rows.Count, cell.Column).End(xlUp).Row
Set RowRange = Range(Cells(2, cell.Column), Cells(LastRow, cell.Column))

RowRange.Copy Destination:=Sheets(SecondSheet).Cells(2, cell.Column)
Else

Sheets(SecondSheet).Activate
Cells(1, cell.Column) = cell

Set PasteRange = Sheets(SecondSheet).Range(Cells(2, cell.Column), _
Cells(25, cell.Column))

PasteRange.Select
Selection = 0

End If


Please help
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,339
Default Please help really need this to work

Is this better?

I am not sure about what to do if 102 is missing in Sheet1. Currently cells
under 102 are set to 0.

Sub copycells()
Const FirstSheet = "sheet1"
Const SecondSheet = "sheet2"


Sheets(SecondSheet).Activate
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column

Set HeaderRange = Range(Cells(1, 1), Cells(1, LastColumn))

col = 1

For Each cell In HeaderRange

col = Application.Match(cell, Sheets(FirstSheet).Range("1:1"), 0)
If IsNumeric(col) Then

Sheets(FirstSheet).Activate
LastRow = Cells(Rows.Count, col).End(xlUp).Row
Set RowRange = Range(Cells(2, col), Cells(LastRow, col))
RowRange.Copy Destination:=Sheets(SecondSheet).Cells(2, cell.Column)
Else

Sheets(SecondSheet).Activate
Set PasteRange = Sheets(SecondSheet).Range(Cells(2, cell.Column), _
Cells(25, cell.Column))

PasteRange.Select
Selection = 0

End If
Next

End Sub

HTH

"Arain" wrote:

have a spread sheet with column A and B being static but Column C1 has a
value 101 and D has 102 and so on till 900. What I want to do is that compare
C1 with another sheet that is in same format but missing number in between
for example its has C1=101 and D1=103. If C101 is there i need to copy all
value in that column to sheet 2 underneath C101 but if D1 is 103 then it
should put 0' in D1=102 from D2 - D25. let me know if there can be any macro
written to compare and copy the values.

If you dont understand anypart please feel free to ask as many questions

Your help will be life saver.

Regards

Arain


Joel wrote this code but its not working please let me know if you can fix it.


To explain in detail. The first sheet looks like this

c d e
101 103 104
2256 2223 3345

sheet 2 looks like this

C D E F
101 102 103 104

Now i want to check if 101 exist in sheet 1 copy all values underneath that
column to sheet 2 till C25

If 102 does not exist replace the cell with D25

if 103 exist copy all value undernead 103 to sheet 2 and so on.

Sub copycells()
Const FirstSheet = "sheet1"
Const SecondSheet = "sheet2"


Sheets(FirstSheet).Activate
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column

Set HeaderRange = Range(Cells(1, "C"), Cells(1, LastColumn))

For Each cell In HeaderRange

If cell = Sheets(SecondSheet).Cells(cell.Row, cell.Column) Then

Sheets(FirstSheet).Activate
LastRow = Cells(Rows.Count, cell.Column).End(xlUp).Row
Set RowRange = Range(Cells(2, cell.Column), Cells(LastRow, cell.Column))

RowRange.Copy Destination:=Sheets(SecondSheet).Cells(2, cell.Column)
Else

Sheets(SecondSheet).Activate
Cells(1, cell.Column) = cell

Set PasteRange = Sheets(SecondSheet).Range(Cells(2, cell.Column), _
Cells(25, cell.Column))

PasteRange.Select
Selection = 0

End If


Please help

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default Please help really need this to work

Ok it didnt do anything but just put 0 in all columns as soon as it found
that 102 is not in sheet 1 and put 0 for all the rest of them even with
correct data. I want it in a way that if sheet 1 doesnot have 102 and sheet2
has it than just put 0 from 1-25 in row. if there is a match in data for
example of 103 has data in sheet 1 then copy the data for 103 from sheet 1 to
sheet 2 which is about 25 line.

Please help me this is very important for my work. i appreciate all your help

"Toppers" wrote:

Is this better?

I am not sure about what to do if 102 is missing in Sheet1. Currently cells
under 102 are set to 0.

Sub copycells()
Const FirstSheet = "sheet1"
Const SecondSheet = "sheet2"


Sheets(SecondSheet).Activate
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column

Set HeaderRange = Range(Cells(1, 1), Cells(1, LastColumn))

col = 1

For Each cell In HeaderRange

col = Application.Match(cell, Sheets(FirstSheet).Range("1:1"), 0)
If IsNumeric(col) Then

Sheets(FirstSheet).Activate
LastRow = Cells(Rows.Count, col).End(xlUp).Row
Set RowRange = Range(Cells(2, col), Cells(LastRow, col))
RowRange.Copy Destination:=Sheets(SecondSheet).Cells(2, cell.Column)
Else

Sheets(SecondSheet).Activate
Set PasteRange = Sheets(SecondSheet).Range(Cells(2, cell.Column), _
Cells(25, cell.Column))

PasteRange.Select
Selection = 0

End If
Next

End Sub

HTH

"Arain" wrote:

have a spread sheet with column A and B being static but Column C1 has a
value 101 and D has 102 and so on till 900. What I want to do is that compare
C1 with another sheet that is in same format but missing number in between
for example its has C1=101 and D1=103. If C101 is there i need to copy all
value in that column to sheet 2 underneath C101 but if D1 is 103 then it
should put 0' in D1=102 from D2 - D25. let me know if there can be any macro
written to compare and copy the values.

If you dont understand anypart please feel free to ask as many questions

Your help will be life saver.

Regards

Arain


Joel wrote this code but its not working please let me know if you can fix it.


To explain in detail. The first sheet looks like this

c d e
101 103 104
2256 2223 3345

sheet 2 looks like this

C D E F
101 102 103 104

Now i want to check if 101 exist in sheet 1 copy all values underneath that
column to sheet 2 till C25

If 102 does not exist replace the cell with D25

if 103 exist copy all value undernead 103 to sheet 2 and so on.

Sub copycells()
Const FirstSheet = "sheet1"
Const SecondSheet = "sheet2"


Sheets(FirstSheet).Activate
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column

Set HeaderRange = Range(Cells(1, "C"), Cells(1, LastColumn))

For Each cell In HeaderRange

If cell = Sheets(SecondSheet).Cells(cell.Row, cell.Column) Then

Sheets(FirstSheet).Activate
LastRow = Cells(Rows.Count, cell.Column).End(xlUp).Row
Set RowRange = Range(Cells(2, cell.Column), Cells(LastRow, cell.Column))

RowRange.Copy Destination:=Sheets(SecondSheet).Cells(2, cell.Column)
Else

Sheets(SecondSheet).Activate
Cells(1, cell.Column) = cell

Set PasteRange = Sheets(SecondSheet).Range(Cells(2, cell.Column), _
Cells(25, cell.Column))

PasteRange.Select
Selection = 0

End If


Please help

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,339
Default Please help really need this to work

In my test I had 101,103 and 104 in row 1 of Sheet1 and data underneath each
heading.

In Sheet2 I had 101,102,103 and 104 in row 1 but no data in row 2 onwards


It placed the Sheet1 data under the correct headings in Sheet2 with 0s under
102.

I have re-tested and it works OK.

It's getting late here in UK so I'll be signing off soon.


If you want, send sample w/sheet to:

toppers at REMOVETHISjohn.topley.fsnet.co.uk

"Arain" wrote:

Ok it didnt do anything but just put 0 in all columns as soon as it found
that 102 is not in sheet 1 and put 0 for all the rest of them even with
correct data. I want it in a way that if sheet 1 doesnot have 102 and sheet2
has it than just put 0 from 1-25 in row. if there is a match in data for
example of 103 has data in sheet 1 then copy the data for 103 from sheet 1 to
sheet 2 which is about 25 line.

Please help me this is very important for my work. i appreciate all your help

"Toppers" wrote:

Is this better?

I am not sure about what to do if 102 is missing in Sheet1. Currently cells
under 102 are set to 0.

Sub copycells()
Const FirstSheet = "sheet1"
Const SecondSheet = "sheet2"


Sheets(SecondSheet).Activate
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column

Set HeaderRange = Range(Cells(1, 1), Cells(1, LastColumn))

col = 1

For Each cell In HeaderRange

col = Application.Match(cell, Sheets(FirstSheet).Range("1:1"), 0)
If IsNumeric(col) Then

Sheets(FirstSheet).Activate
LastRow = Cells(Rows.Count, col).End(xlUp).Row
Set RowRange = Range(Cells(2, col), Cells(LastRow, col))
RowRange.Copy Destination:=Sheets(SecondSheet).Cells(2, cell.Column)
Else

Sheets(SecondSheet).Activate
Set PasteRange = Sheets(SecondSheet).Range(Cells(2, cell.Column), _
Cells(25, cell.Column))

PasteRange.Select
Selection = 0

End If
Next

End Sub

HTH

"Arain" wrote:

have a spread sheet with column A and B being static but Column C1 has a
value 101 and D has 102 and so on till 900. What I want to do is that compare
C1 with another sheet that is in same format but missing number in between
for example its has C1=101 and D1=103. If C101 is there i need to copy all
value in that column to sheet 2 underneath C101 but if D1 is 103 then it
should put 0' in D1=102 from D2 - D25. let me know if there can be any macro
written to compare and copy the values.

If you dont understand anypart please feel free to ask as many questions

Your help will be life saver.

Regards

Arain


Joel wrote this code but its not working please let me know if you can fix it.


To explain in detail. The first sheet looks like this

c d e
101 103 104
2256 2223 3345

sheet 2 looks like this

C D E F
101 102 103 104

Now i want to check if 101 exist in sheet 1 copy all values underneath that
column to sheet 2 till C25

If 102 does not exist replace the cell with D25

if 103 exist copy all value undernead 103 to sheet 2 and so on.

Sub copycells()
Const FirstSheet = "sheet1"
Const SecondSheet = "sheet2"


Sheets(FirstSheet).Activate
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column

Set HeaderRange = Range(Cells(1, "C"), Cells(1, LastColumn))

For Each cell In HeaderRange

If cell = Sheets(SecondSheet).Cells(cell.Row, cell.Column) Then

Sheets(FirstSheet).Activate
LastRow = Cells(Rows.Count, cell.Column).End(xlUp).Row
Set RowRange = Range(Cells(2, cell.Column), Cells(LastRow, cell.Column))

RowRange.Copy Destination:=Sheets(SecondSheet).Cells(2, cell.Column)
Else

Sheets(SecondSheet).Activate
Cells(1, cell.Column) = cell

Set PasteRange = Sheets(SecondSheet).Range(Cells(2, cell.Column), _
Cells(25, cell.Column))

PasteRange.Select
Selection = 0

End If


Please help

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,339
Default Please help really need this to work

Sorry ...typo ( I said it's getting late!)

toppers at REMOVETHISjohntopley.fsnet.co.uk


"Toppers" wrote:

In my test I had 101,103 and 104 in row 1 of Sheet1 and data underneath each
heading.

In Sheet2 I had 101,102,103 and 104 in row 1 but no data in row 2 onwards


It placed the Sheet1 data under the correct headings in Sheet2 with 0s under
102.

I have re-tested and it works OK.

It's getting late here in UK so I'll be signing off soon.


If you want, send sample w/sheet to:

toppers at REMOVETHISjohn.topley.fsnet.co.uk

"Arain" wrote:

Ok it didnt do anything but just put 0 in all columns as soon as it found
that 102 is not in sheet 1 and put 0 for all the rest of them even with
correct data. I want it in a way that if sheet 1 doesnot have 102 and sheet2
has it than just put 0 from 1-25 in row. if there is a match in data for
example of 103 has data in sheet 1 then copy the data for 103 from sheet 1 to
sheet 2 which is about 25 line.

Please help me this is very important for my work. i appreciate all your help

"Toppers" wrote:

Is this better?

I am not sure about what to do if 102 is missing in Sheet1. Currently cells
under 102 are set to 0.

Sub copycells()
Const FirstSheet = "sheet1"
Const SecondSheet = "sheet2"


Sheets(SecondSheet).Activate
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column

Set HeaderRange = Range(Cells(1, 1), Cells(1, LastColumn))

col = 1

For Each cell In HeaderRange

col = Application.Match(cell, Sheets(FirstSheet).Range("1:1"), 0)
If IsNumeric(col) Then

Sheets(FirstSheet).Activate
LastRow = Cells(Rows.Count, col).End(xlUp).Row
Set RowRange = Range(Cells(2, col), Cells(LastRow, col))
RowRange.Copy Destination:=Sheets(SecondSheet).Cells(2, cell.Column)
Else

Sheets(SecondSheet).Activate
Set PasteRange = Sheets(SecondSheet).Range(Cells(2, cell.Column), _
Cells(25, cell.Column))

PasteRange.Select
Selection = 0

End If
Next

End Sub

HTH

"Arain" wrote:

have a spread sheet with column A and B being static but Column C1 has a
value 101 and D has 102 and so on till 900. What I want to do is that compare
C1 with another sheet that is in same format but missing number in between
for example its has C1=101 and D1=103. If C101 is there i need to copy all
value in that column to sheet 2 underneath C101 but if D1 is 103 then it
should put 0' in D1=102 from D2 - D25. let me know if there can be any macro
written to compare and copy the values.

If you dont understand anypart please feel free to ask as many questions

Your help will be life saver.

Regards

Arain


Joel wrote this code but its not working please let me know if you can fix it.


To explain in detail. The first sheet looks like this

c d e
101 103 104
2256 2223 3345

sheet 2 looks like this

C D E F
101 102 103 104

Now i want to check if 101 exist in sheet 1 copy all values underneath that
column to sheet 2 till C25

If 102 does not exist replace the cell with D25

if 103 exist copy all value undernead 103 to sheet 2 and so on.

Sub copycells()
Const FirstSheet = "sheet1"
Const SecondSheet = "sheet2"


Sheets(FirstSheet).Activate
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column

Set HeaderRange = Range(Cells(1, "C"), Cells(1, LastColumn))

For Each cell In HeaderRange

If cell = Sheets(SecondSheet).Cells(cell.Row, cell.Column) Then

Sheets(FirstSheet).Activate
LastRow = Cells(Rows.Count, cell.Column).End(xlUp).Row
Set RowRange = Range(Cells(2, cell.Column), Cells(LastRow, cell.Column))

RowRange.Copy Destination:=Sheets(SecondSheet).Cells(2, cell.Column)
Else

Sheets(SecondSheet).Activate
Cells(1, cell.Column) = cell

Set PasteRange = Sheets(SecondSheet).Range(Cells(2, cell.Column), _
Cells(25, cell.Column))

PasteRange.Select
Selection = 0

End If


Please help



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default Please help really need this to work

i have sent you a worksheet please let me know if it makes sense. thanks alot

"Toppers" wrote:

Sorry ...typo ( I said it's getting late!)

toppers at REMOVETHISjohntopley.fsnet.co.uk


"Toppers" wrote:

In my test I had 101,103 and 104 in row 1 of Sheet1 and data underneath each
heading.

In Sheet2 I had 101,102,103 and 104 in row 1 but no data in row 2 onwards


It placed the Sheet1 data under the correct headings in Sheet2 with 0s under
102.

I have re-tested and it works OK.

It's getting late here in UK so I'll be signing off soon.


If you want, send sample w/sheet to:

toppers at REMOVETHISjohn.topley.fsnet.co.uk

"Arain" wrote:

Ok it didnt do anything but just put 0 in all columns as soon as it found
that 102 is not in sheet 1 and put 0 for all the rest of them even with
correct data. I want it in a way that if sheet 1 doesnot have 102 and sheet2
has it than just put 0 from 1-25 in row. if there is a match in data for
example of 103 has data in sheet 1 then copy the data for 103 from sheet 1 to
sheet 2 which is about 25 line.

Please help me this is very important for my work. i appreciate all your help

"Toppers" wrote:

Is this better?

I am not sure about what to do if 102 is missing in Sheet1. Currently cells
under 102 are set to 0.

Sub copycells()
Const FirstSheet = "sheet1"
Const SecondSheet = "sheet2"


Sheets(SecondSheet).Activate
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column

Set HeaderRange = Range(Cells(1, 1), Cells(1, LastColumn))

col = 1

For Each cell In HeaderRange

col = Application.Match(cell, Sheets(FirstSheet).Range("1:1"), 0)
If IsNumeric(col) Then

Sheets(FirstSheet).Activate
LastRow = Cells(Rows.Count, col).End(xlUp).Row
Set RowRange = Range(Cells(2, col), Cells(LastRow, col))
RowRange.Copy Destination:=Sheets(SecondSheet).Cells(2, cell.Column)
Else

Sheets(SecondSheet).Activate
Set PasteRange = Sheets(SecondSheet).Range(Cells(2, cell.Column), _
Cells(25, cell.Column))

PasteRange.Select
Selection = 0

End If
Next

End Sub

HTH

"Arain" wrote:

have a spread sheet with column A and B being static but Column C1 has a
value 101 and D has 102 and so on till 900. What I want to do is that compare
C1 with another sheet that is in same format but missing number in between
for example its has C1=101 and D1=103. If C101 is there i need to copy all
value in that column to sheet 2 underneath C101 but if D1 is 103 then it
should put 0' in D1=102 from D2 - D25. let me know if there can be any macro
written to compare and copy the values.

If you dont understand anypart please feel free to ask as many questions

Your help will be life saver.

Regards

Arain


Joel wrote this code but its not working please let me know if you can fix it.


To explain in detail. The first sheet looks like this

c d e
101 103 104
2256 2223 3345

sheet 2 looks like this

C D E F
101 102 103 104

Now i want to check if 101 exist in sheet 1 copy all values underneath that
column to sheet 2 till C25

If 102 does not exist replace the cell with D25

if 103 exist copy all value undernead 103 to sheet 2 and so on.

Sub copycells()
Const FirstSheet = "sheet1"
Const SecondSheet = "sheet2"


Sheets(FirstSheet).Activate
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column

Set HeaderRange = Range(Cells(1, "C"), Cells(1, LastColumn))

For Each cell In HeaderRange

If cell = Sheets(SecondSheet).Cells(cell.Row, cell.Column) Then

Sheets(FirstSheet).Activate
LastRow = Cells(Rows.Count, cell.Column).End(xlUp).Row
Set RowRange = Range(Cells(2, cell.Column), Cells(LastRow, cell.Column))

RowRange.Copy Destination:=Sheets(SecondSheet).Cells(2, cell.Column)
Else

Sheets(SecondSheet).Activate
Cells(1, cell.Column) = cell

Set PasteRange = Sheets(SecondSheet).Range(Cells(2, cell.Column), _
Cells(25, cell.Column))

PasteRange.Select
Selection = 0

End If


Please help

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,339
Default Please help really need this to work

No e-mail received:

toppers at REMOVETHISjohntopley.fsnet.co.uk

"Arain" wrote:

i have sent you a worksheet please let me know if it makes sense. thanks alot

"Toppers" wrote:

Sorry ...typo ( I said it's getting late!)

toppers at REMOVETHISjohntopley.fsnet.co.uk


"Toppers" wrote:

In my test I had 101,103 and 104 in row 1 of Sheet1 and data underneath each
heading.

In Sheet2 I had 101,102,103 and 104 in row 1 but no data in row 2 onwards


It placed the Sheet1 data under the correct headings in Sheet2 with 0s under
102.

I have re-tested and it works OK.

It's getting late here in UK so I'll be signing off soon.


If you want, send sample w/sheet to:

toppers at REMOVETHISjohn.topley.fsnet.co.uk

"Arain" wrote:

Ok it didnt do anything but just put 0 in all columns as soon as it found
that 102 is not in sheet 1 and put 0 for all the rest of them even with
correct data. I want it in a way that if sheet 1 doesnot have 102 and sheet2
has it than just put 0 from 1-25 in row. if there is a match in data for
example of 103 has data in sheet 1 then copy the data for 103 from sheet 1 to
sheet 2 which is about 25 line.

Please help me this is very important for my work. i appreciate all your help

"Toppers" wrote:

Is this better?

I am not sure about what to do if 102 is missing in Sheet1. Currently cells
under 102 are set to 0.

Sub copycells()
Const FirstSheet = "sheet1"
Const SecondSheet = "sheet2"


Sheets(SecondSheet).Activate
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column

Set HeaderRange = Range(Cells(1, 1), Cells(1, LastColumn))

col = 1

For Each cell In HeaderRange

col = Application.Match(cell, Sheets(FirstSheet).Range("1:1"), 0)
If IsNumeric(col) Then

Sheets(FirstSheet).Activate
LastRow = Cells(Rows.Count, col).End(xlUp).Row
Set RowRange = Range(Cells(2, col), Cells(LastRow, col))
RowRange.Copy Destination:=Sheets(SecondSheet).Cells(2, cell.Column)
Else

Sheets(SecondSheet).Activate
Set PasteRange = Sheets(SecondSheet).Range(Cells(2, cell.Column), _
Cells(25, cell.Column))

PasteRange.Select
Selection = 0

End If
Next

End Sub

HTH

"Arain" wrote:

have a spread sheet with column A and B being static but Column C1 has a
value 101 and D has 102 and so on till 900. What I want to do is that compare
C1 with another sheet that is in same format but missing number in between
for example its has C1=101 and D1=103. If C101 is there i need to copy all
value in that column to sheet 2 underneath C101 but if D1 is 103 then it
should put 0' in D1=102 from D2 - D25. let me know if there can be any macro
written to compare and copy the values.

If you dont understand anypart please feel free to ask as many questions

Your help will be life saver.

Regards

Arain


Joel wrote this code but its not working please let me know if you can fix it.


To explain in detail. The first sheet looks like this

c d e
101 103 104
2256 2223 3345

sheet 2 looks like this

C D E F
101 102 103 104

Now i want to check if 101 exist in sheet 1 copy all values underneath that
column to sheet 2 till C25

If 102 does not exist replace the cell with D25

if 103 exist copy all value undernead 103 to sheet 2 and so on.

Sub copycells()
Const FirstSheet = "sheet1"
Const SecondSheet = "sheet2"


Sheets(FirstSheet).Activate
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column

Set HeaderRange = Range(Cells(1, "C"), Cells(1, LastColumn))

For Each cell In HeaderRange

If cell = Sheets(SecondSheet).Cells(cell.Row, cell.Column) Then

Sheets(FirstSheet).Activate
LastRow = Cells(Rows.Count, cell.Column).End(xlUp).Row
Set RowRange = Range(Cells(2, cell.Column), Cells(LastRow, cell.Column))

RowRange.Copy Destination:=Sheets(SecondSheet).Cells(2, cell.Column)
Else

Sheets(SecondSheet).Activate
Cells(1, cell.Column) = cell

Set PasteRange = Sheets(SecondSheet).Range(Cells(2, cell.Column), _
Cells(25, cell.Column))

PasteRange.Select
Selection = 0

End If


Please help

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
Counting dates in multiple work sheets and work books Savage Excel Discussion (Misc queries) 0 December 19th 05 11:41 PM
I wish to save my Excell work in my work sheets CLC 37 Qld Excel Worksheet Functions 0 May 24th 05 10:56 AM
Is there away to keep "auto save" from jumping to the first work sheet in the work book? Marc New Users to Excel 2 April 21st 05 01:27 AM
simultaneously work in a work book with other users Sweets Excel Discussion (Misc queries) 1 April 18th 05 07:35 PM
Spin button in a work sheet - how do I make it work? [email protected] Excel Worksheet Functions 1 April 7th 05 08:43 PM


All times are GMT +1. The time now is 08:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"