Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22
Default NEED a MAJOR help with SHEETS copying MACRO

Hello,

I am trying to copy and column J from an odd number (starting from 05) sheet
to even number sheet:

For example:

copy Column J of 05-Test (Sheet name) and paste column J of 06-Test (Sheet
name)

so on for 07-Test to 08-Test, Up to 25-Test to 26-Test.


Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default NEED a MAJOR help with SHEETS copying MACRO

Sub CopyColJ()

For Each sht In Sheets

If UCase(Right(Trim(sht.Name), 5)) = "-TEST" Then
ShtNum = Val(sht.Name)
'test if sheet number is odd
If ShtNum Mod 2 = 1 Then
NextShtName = Format(ShtNum + 1, "#00") & _
"-Test"
sht.Columns("J").Copy _
Destination:=Sheets(NextShtName).Columns("J")
End If
End If

Next sht


End Sub

"bioyyy" wrote:

Hello,

I am trying to copy and column J from an odd number (starting from 05) sheet
to even number sheet:

For example:

copy Column J of 05-Test (Sheet name) and paste column J of 06-Test (Sheet
name)

so on for 07-Test to 08-Test, Up to 25-Test to 26-Test.


Thanks

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default NEED a MAJOR help with SHEETS copying MACRO

Try the macro
'Note: No error checking
Sub copyToAlternateSheets()
Dim i As Integer
Dim ws As Worksheet
Dim srcName, destName As String

For i = 5 To 13 Step 2
If i < 10 Then
srcName = "0" & i & "-Test"
destName = "0" & (i + 1) & "-Test"
Else
srcName = i & "-Test"
destName = (i + 1) & "-Test"
End If
If i = 9 Then
srcName = "0" & i & "-Test"
destName = (i + 1) & "-Test"
End If
Set ws = Worksheets(srcName)
If (ws.Name < "") Then
Worksheets(srcName).Activate
ActiveSheet.Columns("J:J").Copy
Worksheets(destName).Activate
ActiveSheet.Range("J1").Select
ActiveSheet.Paste
End If
Next i
End Sub


"bioyyy" wrote:

Hello,

I am trying to copy and column J from an odd number (starting from 05) sheet
to even number sheet:

For example:

copy Column J of 05-Test (Sheet name) and paste column J of 06-Test (Sheet
name)

so on for 07-Test to 08-Test, Up to 25-Test to 26-Test.


Thanks

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22
Default NEED a MAJOR help with SHEETS copying MACRO

Joel and Sheelo:

Thanks for your BIG help! But I made one big mistake in my question.

The sheet names are not the same as I wrote Test. Actually, each sheet has
different names (i.e. 05-ABC, 06-Test, 07-adge, 08-iesdf, .....For example).
I hope you can help me to fix it. Thanks again,



"Sheeloo" wrote:

Try the macro
'Note: No error checking
Sub copyToAlternateSheets()
Dim i As Integer
Dim ws As Worksheet
Dim srcName, destName As String

For i = 5 To 13 Step 2
If i < 10 Then
srcName = "0" & i & "-Test"
destName = "0" & (i + 1) & "-Test"
Else
srcName = i & "-Test"
destName = (i + 1) & "-Test"
End If
If i = 9 Then
srcName = "0" & i & "-Test"
destName = (i + 1) & "-Test"
End If
Set ws = Worksheets(srcName)
If (ws.Name < "") Then
Worksheets(srcName).Activate
ActiveSheet.Columns("J:J").Copy
Worksheets(destName).Activate
ActiveSheet.Range("J1").Select
ActiveSheet.Paste
End If
Next i
End Sub


"bioyyy" wrote:

Hello,

I am trying to copy and column J from an odd number (starting from 05) sheet
to even number sheet:

For example:

copy Column J of 05-Test (Sheet name) and paste column J of 06-Test (Sheet
name)

so on for 07-Test to 08-Test, Up to 25-Test to 26-Test.


Thanks

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default NEED a MAJOR help with SHEETS copying MACRO

Try
Sub copyToAlternateSheets()
Dim i As Integer
Dim ws, dest As Worksheet
Dim srcName, destName As String
Dim wksNumber
For Each ws In Worksheets
wksNumber = CInt(Left(ws.Name, 2))
If (wksNumber Mod 2) = 1 Then
srcName = ws.Name
For Each dest In Worksheets
If CInt(Left(dest.Name, 2)) = "0" & (wksNumber + 1) Then
destName = dest.Name
Exit For
End If
Next dest
Worksheets(srcName).Activate
ActiveSheet.Columns("J:J").Copy
Worksheets(destName).Activate
ActiveSheet.Range("J1").Select
ActiveSheet.Paste
End If
Next ws
End Sub

"bioyyy" wrote:

Joel and Sheelo:

Thanks for your BIG help! But I made one big mistake in my question.

The sheet names are not the same as I wrote Test. Actually, each sheet has
different names (i.e. 05-ABC, 06-Test, 07-adge, 08-iesdf, .....For example).
I hope you can help me to fix it. Thanks again,





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
Need Major Help on the Macro bioyyy Excel Discussion (Misc queries) 12 October 25th 08 11:43 AM
Copying Sheets LiAD Excel Worksheet Functions 1 September 10th 08 04:55 PM
Copying sheets in a macro jhyatt Excel Discussion (Misc queries) 0 October 3rd 07 07:17 PM
Linking sheets into one major sheet? Ellymoo Excel Worksheet Functions 8 April 24th 06 11:22 AM
Copying Macro w/ different sheets liseladele Excel Worksheet Functions 1 March 22nd 06 01:43 AM


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