Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Checking contents

I have a report on a sheet in excel. The report shows
every invoice to be included in a payment run and has lots
of different data in seperate columns.

The supplier reference is in Column H and i would like to
copy all rows with that supplier reference to a new sheet
and then save that sheet by a specific cell in that sheet.

The could be any number of invoices for each supplier so
the macro will have somehow copy the first row and then
somehow check to see if the next cell is equal to the last.

Does anyone have any ideas on how to do this?

Thanks

Edgar
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Checking contents

Edgar,

Here's a macro to do it

Sub CopyInvoices()
Dim sCriteria As String
Dim sOriginal As String
Dim sNew As String

sCriteria = InputBox("Input Supplier Ref to select")
If sCriteria < "" Then
With ActiveWorkbook
sOriginal = .ActiveSheet.Name
.Worksheets.Add After:=.Worksheets(.Worksheets.Count)
.ActiveSheet.Name = sCriteria
sNew = .ActiveSheet.Name
.Worksheets(sOriginal).Activate
With .ActiveSheet
.Rows(1).Insert
.Range("H1").Value = "Test"
.Columns("H:H").AutoFilter Field:=1, Criteria1:=sCriteria
.Cells.SpecialCells(xlCellTypeVisible).Copy
End With
.Worksheets(sNew).Paste
.Worksheets(sNew).Rows(1).EntireRow.Delete
.Worksheets(sOriginal).Rows(1).EntireRow.Delete
End With
End If

Application.CutCopyMode = False

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Edgar Thoemmes" wrote in message
...
I have a report on a sheet in excel. The report shows
every invoice to be included in a payment run and has lots
of different data in seperate columns.

The supplier reference is in Column H and i would like to
copy all rows with that supplier reference to a new sheet
and then save that sheet by a specific cell in that sheet.

The could be any number of invoices for each supplier so
the macro will have somehow copy the first row and then
somehow check to see if the next cell is equal to the last.

Does anyone have any ideas on how to do this?

Thanks

Edgar



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Checking contents

Hi

This works well but there are a couple of problems that I
need to sort.

Firstly instead of having an inputbox to name the new
sheet i would like the values to be copied to a new
workbook and to name the workbook by the value in
column "T".

I would also like the macro to loop through the entire
sheet and finish when it gets to the end.

Thanks



-----Original Message-----
Edgar,

Here's a macro to do it

Sub CopyInvoices()
Dim sCriteria As String
Dim sOriginal As String
Dim sNew As String

sCriteria = InputBox("Input Supplier Ref to select")
If sCriteria < "" Then
With ActiveWorkbook
sOriginal = .ActiveSheet.Name
.Worksheets.Add After:=.Worksheets

(.Worksheets.Count)
.ActiveSheet.Name = sCriteria
sNew = .ActiveSheet.Name
.Worksheets(sOriginal).Activate
With .ActiveSheet
.Rows(1).Insert
.Range("H1").Value = "Test"
.Columns("H:H").AutoFilter Field:=1,

Criteria1:=sCriteria
.Cells.SpecialCells

(xlCellTypeVisible).Copy
End With
.Worksheets(sNew).Paste
.Worksheets(sNew).Rows(1).EntireRow.Delete
.Worksheets(sOriginal).Rows

(1).EntireRow.Delete
End With
End If

Application.CutCopyMode = False

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Edgar Thoemmes"

wrote in message
...
I have a report on a sheet in excel. The report shows
every invoice to be included in a payment run and has

lots
of different data in seperate columns.

The supplier reference is in Column H and i would like

to
copy all rows with that supplier reference to a new

sheet
and then save that sheet by a specific cell in that

sheet.

The could be any number of invoices for each supplier so
the macro will have somehow copy the first row and then
somehow check to see if the next cell is equal to the

last.

Does anyone have any ideas on how to do this?

Thanks

Edgar



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Checking contents

Edgar,

Where in column T is the criteria. it can't be the whole column?


It already processes the entire sheet, the autofilter process will select
all items that match, so I am, not sure what you mean by the second part.
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Edgar" wrote in message
...
Hi

This works well but there are a couple of problems that I
need to sort.

Firstly instead of having an inputbox to name the new
sheet i would like the values to be copied to a new
workbook and to name the workbook by the value in
column "T".

I would also like the macro to loop through the entire
sheet and finish when it gets to the end.

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Checking contents

Hi Edgar

I use this program to name sheets in VB to the contents of cell A1

Modify as required

--

Kyle


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
concatenate contents of cells whose contents resemble cell referem cathyh Excel Worksheet Functions 3 May 23rd 09 12:16 PM
Spell Checking with checking cell notes jfitzpat Excel Discussion (Misc queries) 0 August 8th 07 10:26 PM
compare the contents of one range of cells with the contents of a. Dozy123 Excel Discussion (Misc queries) 1 January 24th 07 10:14 AM
Checking the length of cell contents RichardG Excel Discussion (Misc queries) 8 February 21st 06 12:37 PM
Macro to remove contents of cell and move all other contents up one row adw223 Excel Discussion (Misc queries) 1 July 1st 05 03:57 PM


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