Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,388
Default Macro Needed

Hi guys,

I'm looking for help with the macro below.

What it does at the moment is:

Delete Column A
Delete Column C
Delete Rows 1 to 7
Delete Column C to BA
Autofit Rows A and B
Insert 6 Columns
Split the Data in Column A using 'Text to Columns' (See below for settings)
Delete Columns B to F
This then leaves me with a Name in Column A and a Date in column B.

The problem I have however is with the section that "Delete Columns B to F"

What I would like to happen is:

The macro looks through Rows A to G
If there is a value in Row G, Delete Rows A to F
If there is no value in Row G, but there is a Value in Row F, Delete Rows A
to E and Row G

etc. etc.

Can anyone help me with this?

Thanks
Dave




Macro below:-

Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Columns("C:C").Select
Selection.Delete Shift:=xlToLeft
Rows("1:7").Select
Range("A7").Activate
Selection.Delete Shift:=xlUp
Columns("C:BA").Select
Selection.Delete Shift:=xlToLeft
Columns("B:B").Select
Columns("B:B").EntireColumn.AutoFit
Columns("A:A").Select
Columns("A:A").EntireColumn.AutoFit
Columns("B:B").Select

'Insert 6 columns

Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight


'Split Column A into Individual Names/Words i.e. First Name / Middle
Name /
'Surname /

Columns("A:A").Select

Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True,
Tab:=False, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Columns("B:F").Select
Selection.Delete Shift:=xlToLeft


'Convert Column B into Date Format

Columns("B:B").Select
Selection.NumberFormat = "dd/mm/yyyy"
Range("C1").Select
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Macro Needed

You said rows when you may have meant columns. You said b-f and then a-f. I
assume you wanted to keep col A. Sounds like this may work for part of it.
If you post before/after examples or send a workbook I can help with the
rest. Selections are NOT necessary or desirable.

Sub deletecolumnsif()
mr = ActiveCell.Row
lc = Cells(mr, Columns.Count).End(xlToLeft).Column
Columns(lc + 1).Delete
Range(Cells(mr, 2), Cells(lc - 1)).EntireColumn.Delete
columns("a:b").autofit
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Dave" wrote in message
...
Hi guys,

I'm looking for help with the macro below.

What it does at the moment is:

Delete Column A
Delete Column C
Delete Rows 1 to 7
Delete Column C to BA
Autofit Rows A and B
Insert 6 Columns
Split the Data in Column A using 'Text to Columns' (See below for
settings)
Delete Columns B to F
This then leaves me with a Name in Column A and a Date in column B.

The problem I have however is with the section that "Delete Columns B to
F"

What I would like to happen is:

The macro looks through Rows A to G
If there is a value in Row G, Delete Rows A to F
If there is no value in Row G, but there is a Value in Row F, Delete Rows
A
to E and Row G

etc. etc.

Can anyone help me with this?

Thanks
Dave




Macro below:-

Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Columns("C:C").Select
Selection.Delete Shift:=xlToLeft
Rows("1:7").Select
Range("A7").Activate
Selection.Delete Shift:=xlUp
Columns("C:BA").Select
Selection.Delete Shift:=xlToLeft
Columns("B:B").Select
Columns("B:B").EntireColumn.AutoFit
Columns("A:A").Select
Columns("A:A").EntireColumn.AutoFit
Columns("B:B").Select

'Insert 6 columns

Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight


'Split Column A into Individual Names/Words i.e. First Name / Middle
Name /
'Surname /

Columns("A:A").Select

Selection.TextToColumns Destination:=Range("A1"),
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True,
Tab:=False, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False,
FieldInfo _
:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Columns("B:F").Select
Selection.Delete Shift:=xlToLeft


'Convert Column B into Date Format

Columns("B:B").Select
Selection.NumberFormat = "dd/mm/yyyy"
Range("C1").Select


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
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro needed to set macro security in Excel to minimum Carl Excel Programming 3 March 18th 06 03:36 PM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 0 June 10th 05 03:38 PM
Macro help needed... sameer27p[_16_] Excel Programming 0 July 21st 04 04:54 PM


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