Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Simple problem with code

I've got a mutli tab workbook, one sheet is titled PAYMENT LIST. I'm using
this code to copy all rows with DISC in Col A to a new sheet titled DISC
PMTS. For some reason this isn't working and I just can't seem to figure out
why. Any help you can give me is certainly appreciated.

Sub CopyDiscPaymentsToNewSheet()

Dim i As Long, Sh As Worksheet
With Worksheets("PAYMENT LIST")
Set rng = .Range(.Cells(1, "A"), _
.Cells(Rows.Count, "A").End(xlUp))
End With
i = 1

Set Sh = Worksheets("DISC PMTS")
For Each cell In rng

If UCase(Trim(cell.Offset(0, 1).Value)) = "DISC PMTS" Then
cell.EntireRow.Copy Sh.Cells(i, 1)
i = i + 1
End If

Next

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Simple problem with code

First you are looking at cell.Offset(0, 1).Value which is column B rather
than column A.


Second you are looking for DISC PMTS to be in the cell rather than DISC
--
Gary's Student


"JOUIOUI" wrote:

I've got a mutli tab workbook, one sheet is titled PAYMENT LIST. I'm using
this code to copy all rows with DISC in Col A to a new sheet titled DISC
PMTS. For some reason this isn't working and I just can't seem to figure out
why. Any help you can give me is certainly appreciated.

Sub CopyDiscPaymentsToNewSheet()

Dim i As Long, Sh As Worksheet
With Worksheets("PAYMENT LIST")
Set rng = .Range(.Cells(1, "A"), _
.Cells(Rows.Count, "A").End(xlUp))
End With
i = 1

Set Sh = Worksheets("DISC PMTS")
For Each cell In rng

If UCase(Trim(cell.Offset(0, 1).Value)) = "DISC PMTS" Then
cell.EntireRow.Copy Sh.Cells(i, 1)
i = i + 1
End If

Next

End Sub


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
Simple problem, simple formula, no FUNCTION ! Ron@Buy Excel Worksheet Functions 6 September 28th 07 04:51 PM
Problem with a very simple code in Visual basic Vepa Excel Programming 4 January 25th 06 03:42 PM
need a simple code Peter McCaul Excel Programming 1 August 11th 04 08:13 PM
simple code problem Dave W[_3_] Excel Programming 4 June 29th 04 09:54 PM


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