Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jc jc is offline
external usenet poster
 
Posts: 164
Default Creating a macro

Hi guys/gals...

I'm NOT at all good with writing macros...in fact, i've never really written
one and i'm trying it out...i have a multiple command macro that i'm trying
to write below...can some one simplify it for me so i can get it to work...i
just want my people to push a button on my spreadsheet..I have everything set
up, but the macro code wont' work...

People will copy data from one sheet and paste it into my "macro" sheet and
then the macro will format it for them...i think it should be pretty simple!!

Thanks in advance!!!
~JC

Cells.Select
Selection.UnMerge
ActiveCell.Offset(0, 5).Columns("A:A").EntireColumn.Select
Selection.Copy
ActiveCell.Offset(0, 3).Columns("A:A").EntireColumn.Select
ActiveSheet.Paste
ActiveCell.Offset(0, -8).Columns("A:H").EntireColumn.Select
ActiveCell.Offset(0, -1).Range("A1").Activate
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
ActiveCell.Offset(0, -7).Columns("A:A").EntireColumn.Select
ActiveSheet.Range("$A$1:$A$456").RemoveDuplicates Columns:=1, Header:=xlNo
ActiveCell.Rows("1:2").EntireRow.Select
Selection.Delete Shift:=xlUp


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Creating a macro

Hi JC, what you should do is record your macro and then try to clean it up.
Simply turn on the recorder: Tools, MacroRecord New Macro and begin
manually doing what you want the macro to do. A toolbar will appear with the
Stop Recording button on it. When you have completed doing what you want in
the macro, click that button. You don't have to hurry, if you don't make any
input the recorder is just waiting on you. Test your macro to be sure it is
what you want, then post back to the NG for someone to help clean it up.

The one you posted is too ambiguous to determine exactly what you want to do.

"JC" wrote:

Hi guys/gals...

I'm NOT at all good with writing macros...in fact, i've never really written
one and i'm trying it out...i have a multiple command macro that i'm trying
to write below...can some one simplify it for me so i can get it to work...i
just want my people to push a button on my spreadsheet..I have everything set
up, but the macro code wont' work...

People will copy data from one sheet and paste it into my "macro" sheet and
then the macro will format it for them...i think it should be pretty simple!!

Thanks in advance!!!
~JC

Cells.Select
Selection.UnMerge
ActiveCell.Offset(0, 5).Columns("A:A").EntireColumn.Select
Selection.Copy
ActiveCell.Offset(0, 3).Columns("A:A").EntireColumn.Select
ActiveSheet.Paste
ActiveCell.Offset(0, -8).Columns("A:H").EntireColumn.Select
ActiveCell.Offset(0, -1).Range("A1").Activate
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
ActiveCell.Offset(0, -7).Columns("A:A").EntireColumn.Select
ActiveSheet.Range("$A$1:$A$456").RemoveDuplicates Columns:=1, Header:=xlNo
ActiveCell.Rows("1:2").EntireRow.Select
Selection.Delete Shift:=xlUp


  #3   Report Post  
Posted to microsoft.public.excel.programming
jc jc is offline
external usenet poster
 
Posts: 164
Default Creating a macro

JLGWhiz,
Thanks for your reply!! Here's the "straight" macro recording..

Cells.Select
Application.CutCopyMode = False
Selection.UnMerge
Rows("1:12").Select
Selection.Delete Shift:=xlUp
Columns("A:E").Select
Range("E1").Activate
Selection.Delete Shift:=xlToLeft
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Columns("A:A").Select
ActiveSheet.Range("$A$1:$A$456").RemoveDuplicates Columns:=1, Header:=xlNo
Rows("1:2").Select
Range("A2").Activate
Selection.Delete Shift:=xlUp
Range("C4").Select
End Sub

In English here's what I need to do:
1. Select all and unmerge
2. Delete rows 1-12
3. Delete Columns A:E
4. Delete Column B
5. Remove Duplicates
6. Delete Rows 1:2
7. Done.

Thanks again for your help!!
~JC



"JLGWhiz" wrote:

Hi JC, what you should do is record your macro and then try to clean it up.
Simply turn on the recorder: Tools, MacroRecord New Macro and begin
manually doing what you want the macro to do. A toolbar will appear with the
Stop Recording button on it. When you have completed doing what you want in
the macro, click that button. You don't have to hurry, if you don't make any
input the recorder is just waiting on you. Test your macro to be sure it is
what you want, then post back to the NG for someone to help clean it up.

The one you posted is too ambiguous to determine exactly what you want to do.

"JC" wrote:

Hi guys/gals...

I'm NOT at all good with writing macros...in fact, i've never really written
one and i'm trying it out...i have a multiple command macro that i'm trying
to write below...can some one simplify it for me so i can get it to work...i
just want my people to push a button on my spreadsheet..I have everything set
up, but the macro code wont' work...

People will copy data from one sheet and paste it into my "macro" sheet and
then the macro will format it for them...i think it should be pretty simple!!

Thanks in advance!!!
~JC

Cells.Select
Selection.UnMerge
ActiveCell.Offset(0, 5).Columns("A:A").EntireColumn.Select
Selection.Copy
ActiveCell.Offset(0, 3).Columns("A:A").EntireColumn.Select
ActiveSheet.Paste
ActiveCell.Offset(0, -8).Columns("A:H").EntireColumn.Select
ActiveCell.Offset(0, -1).Range("A1").Activate
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
ActiveCell.Offset(0, -7).Columns("A:A").EntireColumn.Select
ActiveSheet.Range("$A$1:$A$456").RemoveDuplicates Columns:=1, Header:=xlNo
ActiveCell.Rows("1:2").EntireRow.Select
Selection.Delete Shift:=xlUp


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Creating a macro

This should do what you want. I only compared data in column A
for the duplicates. If your data is not sorted so that duplicate appear
adjacent to each other then the macro fails.

Sub DeleteStuff()
Dim lr As Long
With ActiveSheet
.Rows("1:12").Delete 'Deletes first 12 rows.
Union(.Columns("A:E"), Columns("G")).Delete 'Deletes first 5 col, then
2nd col.
lr = .Cells(.Rows.Count, 1).End(xlUp).Row 'Finds last row with data
in col A
For i = lr To 2 Step -1
If Cells(i, 1) = Cells(i - 1, 1) Then 'Compares data in first cell
of next row up.
Cells(i, 1).EntireRow.Delete 'Deletes if match is found.
End If
Next
.Rows("1:2").Delete 'Deletes first two rows of remaining data.
End With
End Sub

You did not specify if you had header rows to be considered, therefor, the
macro assumes no header rows. If you have them and want to keep them, you
will need to adjust the macro. To find duplicates without sorting the file,
the macro would have to be changed to use the FindNext method.





"JC" wrote:

JLGWhiz,
Thanks for your reply!! Here's the "straight" macro recording..

Cells.Select
Application.CutCopyMode = False
Selection.UnMerge
Rows("1:12").Select
Selection.Delete Shift:=xlUp
Columns("A:E").Select
Range("E1").Activate
Selection.Delete Shift:=xlToLeft
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Columns("A:A").Select
ActiveSheet.Range("$A$1:$A$456").RemoveDuplicates Columns:=1, Header:=xlNo
Rows("1:2").Select
Range("A2").Activate
Selection.Delete Shift:=xlUp
Range("C4").Select
End Sub

In English here's what I need to do:
1. Select all and unmerge
2. Delete rows 1-12
3. Delete Columns A:E
4. Delete Column B
5. Remove Duplicates
6. Delete Rows 1:2
7. Done.

Thanks again for your help!!
~JC



"JLGWhiz" wrote:

Hi JC, what you should do is record your macro and then try to clean it up.
Simply turn on the recorder: Tools, MacroRecord New Macro and begin
manually doing what you want the macro to do. A toolbar will appear with the
Stop Recording button on it. When you have completed doing what you want in
the macro, click that button. You don't have to hurry, if you don't make any
input the recorder is just waiting on you. Test your macro to be sure it is
what you want, then post back to the NG for someone to help clean it up.

The one you posted is too ambiguous to determine exactly what you want to do.

"JC" wrote:

Hi guys/gals...

I'm NOT at all good with writing macros...in fact, i've never really written
one and i'm trying it out...i have a multiple command macro that i'm trying
to write below...can some one simplify it for me so i can get it to work...i
just want my people to push a button on my spreadsheet..I have everything set
up, but the macro code wont' work...

People will copy data from one sheet and paste it into my "macro" sheet and
then the macro will format it for them...i think it should be pretty simple!!

Thanks in advance!!!
~JC

Cells.Select
Selection.UnMerge
ActiveCell.Offset(0, 5).Columns("A:A").EntireColumn.Select
Selection.Copy
ActiveCell.Offset(0, 3).Columns("A:A").EntireColumn.Select
ActiveSheet.Paste
ActiveCell.Offset(0, -8).Columns("A:H").EntireColumn.Select
ActiveCell.Offset(0, -1).Range("A1").Activate
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
ActiveCell.Offset(0, -7).Columns("A:A").EntireColumn.Select
ActiveSheet.Range("$A$1:$A$456").RemoveDuplicates Columns:=1, Header:=xlNo
ActiveCell.Rows("1:2").EntireRow.Select
Selection.Delete Shift:=xlUp


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
Creating a Macro? Lynda Excel Discussion (Misc queries) 2 July 21st 08 03:07 PM
Help with creating a Macro [email protected] Excel Programming 1 May 4th 07 08:08 PM
Creating a macro which presses a button containing a recorded macro petros89[_3_] Excel Programming 3 October 5th 05 02:49 PM
Creating a macro Gene Goldenfeld New Users to Excel 10 May 5th 05 04:28 PM
help creating a macro ale700 Excel Programming 3 July 6th 04 05:37 AM


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