Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Copy certain columns to another sheet using a macro

I have got this macro:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 24/09/2005 by Shane Nation
'

'
Range("A1,B1,C1,E1,G1,I1:J1,L1:N1").Select
Range("L1").Activate
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
ActiveSheet.Paste
End Sub

Waht I am trying to do is click on call A"n" i.e. selecting different rows
as I move down the sheet, then ru a macro which copys only the columns
a,b,c,e,g,i,n in the selected row. Open a diffresent and paste them at the
current cursur location.

This macro just selts the same cells and pasts them in the same location
each time it is run.

Please can someone help?

Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default Copy certain columns to another sheet using a macro

use a worksheet selection change event

with the VBE paste this code into Thisworkbook
be sure that this workbook has a sheet named "sheet2"

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
Dim myrow As Integer
Dim mycolToCopy As Variant
Dim counter As Integer

mycolToCopy = Array(1, 2, 3, 5, 7, 9, 10, 12, 13, 14) 'your columns
to copy

If Sh.Name = "Sheet1" Then
If Target.Column = 1 Then
myrow = Target.Row ' copy to same row on sht 2

With ActiveWorkbook.Sheets("Sheet2")
For counter = 1 To 10 ' NUMBER OF CELLS TO COPY
.Cells(myrow, counter).Value = Sh.Cells(myrow,
mycolToCopy(counter))
Next counter
End With
End If
End If

End Sub

"Shane Nation" wrote:

I have got this macro:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 24/09/2005 by Shane Nation
'

'
Range("A1,B1,C1,E1,G1,I1:J1,L1:N1").Select
Range("L1").Activate
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
ActiveSheet.Paste
End Sub

Waht I am trying to do is click on call A"n" i.e. selecting different rows
as I move down the sheet, then ru a macro which copys only the columns
a,b,c,e,g,i,n in the selected row. Open a diffresent and paste them at the
current cursur location.

This macro just selts the same cells and pasts them in the same location
each time it is run.

Please can someone help?

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Copy certain columns to another sheet using a macro

Thank you for your help. Can't get it to work, way over my simple head.

Thanks

Shane
"Vacation's Over" wrote in message
...
use a worksheet selection change event

with the VBE paste this code into Thisworkbook
be sure that this workbook has a sheet named "sheet2"

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
Dim myrow As Integer
Dim mycolToCopy As Variant
Dim counter As Integer

mycolToCopy = Array(1, 2, 3, 5, 7, 9, 10, 12, 13, 14) 'your columns
to copy

If Sh.Name = "Sheet1" Then
If Target.Column = 1 Then
myrow = Target.Row ' copy to same row on sht 2

With ActiveWorkbook.Sheets("Sheet2")
For counter = 1 To 10 ' NUMBER OF CELLS TO COPY
.Cells(myrow, counter).Value = Sh.Cells(myrow,
mycolToCopy(counter))
Next counter
End With
End If
End If

End Sub

"Shane Nation" wrote:

I have got this macro:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 24/09/2005 by Shane Nation
'

'
Range("A1,B1,C1,E1,G1,I1:J1,L1:N1").Select
Range("L1").Activate
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
ActiveSheet.Paste
End Sub

Waht I am trying to do is click on call A"n" i.e. selecting different
rows
as I move down the sheet, then ru a macro which copys only the columns
a,b,c,e,g,i,n in the selected row. Open a diffresent and paste them at
the
current cursur location.

This macro just selts the same cells and pasts them in the same location
each time it is run.

Please can someone help?

Thanks





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
How do i copy rows to columns on separate sheet, and have them upd Gre Excel Worksheet Functions 2 November 23rd 06 06:36 PM
Copy a row from one sheet to another and not all columns copy Peaches[_2_] Excel Programming 2 September 7th 05 12:09 PM
Macro to copy columns from 1st sheet to 2nd according to mapping-p Pawan Excel Programming 2 June 22nd 05 05:53 AM
macro to copy columns to sheet Es Excel Discussion (Misc queries) 1 March 7th 05 03:03 PM
How to create a Macro to Copy Information in one sheet to another sheet. poppy Excel Programming 3 July 28th 04 07:26 AM


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