Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default NEED MACRO FOR COLOUR BY CONDITIONAL FORMATTING

Hi, I have data in coloumn A to coloumn E. (please see below)
A B C
D E
000 B10 G628 000B10G628 54
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 000B10 12
000 B10 000B10 13
000 B10 000B10 12
000 B10 000B10 12
in coloumn D i have Formula which is "=A1&B1&C1" as you can see above
and then I put
CONDITIONAL FORMATTING in coloumn D as well in which I put the Formula
which is
"=IF(AND(D2=D3,E2<E3),TRUE)" its mean that if two values in coloumn D
cells are equal but two values in coloumn E are not equal which are
against each other in same cells then its true and the Cell should
get Red colour. so when ever two values in coloumn D are equal but in
next coloumn E the two values are not equal cell get Red colour by
CONDITIONAL FORMATTING.I want MACRO which can copy only those rows in
which coloumn D cells have Red colour to next sheet. Please Note that
cells getting Red colours by CONDITIONAL FORMATTING and whole coloumn
D have CONDITIONAL FORMATTING. Some friend send me macro but it copy
all data to next sheet instead of just coping only those rows in which
coloumn D cells have Red colour by CONDITIONAL FORMATTING. Please if
anybody can help. Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default NEED MACRO FOR COLOUR BY CONDITIONAL FORMATTING

Sub movedata()

OldShRowCount = 1
NewShRowCount = 1
With Sheets("OldSheet")
Do While .Range("D" & OldShRowCount) < ""
If (.Range("D" & OldShRowCount) = _
.Range("D" & (OldShRowCount + 1))) And _
(.Range("E" & OldShRowCount) < _
.Range("E" & (OldShRowCount + 1))) Then

.Rows(OldShRowCount).Copy _
Destination:= _
Sheets("NewSheet").Rows(NewShRowCount)
NewShRowCount = NewShRowCount + 1
End If
OldShRowCount = OldShRowCount + 1
Loop
End With

End Sub


"K" wrote:

Hi, I have data in coloumn A to coloumn E. (please see below)
A B C
D E
000 B10 G628 000B10G628 54
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 000B10 12
000 B10 000B10 13
000 B10 000B10 12
000 B10 000B10 12
in coloumn D i have Formula which is "=A1&B1&C1" as you can see above
and then I put
CONDITIONAL FORMATTING in coloumn D as well in which I put the Formula
which is
"=IF(AND(D2=D3,E2<E3),TRUE)" its mean that if two values in coloumn D
cells are equal but two values in coloumn E are not equal which are
against each other in same cells then its true and the Cell should
get Red colour. so when ever two values in coloumn D are equal but in
next coloumn E the two values are not equal cell get Red colour by
CONDITIONAL FORMATTING.I want MACRO which can copy only those rows in
which coloumn D cells have Red colour to next sheet. Please Note that
cells getting Red colours by CONDITIONAL FORMATTING and whole coloumn
D have CONDITIONAL FORMATTING. Some friend send me macro but it copy
all data to next sheet instead of just coping only those rows in which
coloumn D cells have Red colour by CONDITIONAL FORMATTING. Please if
anybody can help. Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default NEED MACRO FOR COLOUR BY CONDITIONAL FORMATTING

Thanks Joel for replying. how can i amend your macro if i want macro
to copy data into next sheet from row 2 as i will be putting headings
in row 1. And also is there way i can get row copy from cell A to
cell F as with your macro its copying entire row.

Joel wrote:
Sub movedata()

OldShRowCount = 1
NewShRowCount = 1
With Sheets("OldSheet")
Do While .Range("D" & OldShRowCount) < ""
If (.Range("D" & OldShRowCount) = _
.Range("D" & (OldShRowCount + 1))) And _
(.Range("E" & OldShRowCount) < _
.Range("E" & (OldShRowCount + 1))) Then

.Rows(OldShRowCount).Copy _
Destination:= _
Sheets("NewSheet").Rows(NewShRowCount)
NewShRowCount = NewShRowCount + 1
End If
OldShRowCount = OldShRowCount + 1
Loop
End With

End Sub


"K" wrote:

Hi, I have data in coloumn A to coloumn E. (please see below)
A B C
D E
000 B10 G628 000B10G628 54
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 000B10 12
000 B10 000B10 13
000 B10 000B10 12
000 B10 000B10 12
in coloumn D i have Formula which is "=A1&B1&C1" as you can see above
and then I put
CONDITIONAL FORMATTING in coloumn D as well in which I put the Formula
which is
"=IF(AND(D2=D3,E2<E3),TRUE)" its mean that if two values in coloumn D
cells are equal but two values in coloumn E are not equal which are
against each other in same cells then its true and the Cell should
get Red colour. so when ever two values in coloumn D are equal but in
next coloumn E the two values are not equal cell get Red colour by
CONDITIONAL FORMATTING.I want MACRO which can copy only those rows in
which coloumn D cells have Red colour to next sheet. Please Note that
cells getting Red colours by CONDITIONAL FORMATTING and whole coloumn
D have CONDITIONAL FORMATTING. Some friend send me macro but it copy
all data to next sheet instead of just coping only those rows in which
coloumn D cells have Red colour by CONDITIONAL FORMATTING. Please if
anybody can help. Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default NEED MACRO FOR COLOUR BY CONDITIONAL FORMATTING

from
NewShRowCount = 1
to
NewShRowCount = 2


"K" wrote:

Thanks Joel for replying. how can i amend your macro if i want macro
to copy data into next sheet from row 2 as i will be putting headings
in row 1. And also is there way i can get row copy from cell A to
cell F as with your macro its copying entire row.

Joel wrote:
Sub movedata()

OldShRowCount = 1
NewShRowCount = 1
With Sheets("OldSheet")
Do While .Range("D" & OldShRowCount) < ""
If (.Range("D" & OldShRowCount) = _
.Range("D" & (OldShRowCount + 1))) And _
(.Range("E" & OldShRowCount) < _
.Range("E" & (OldShRowCount + 1))) Then

.Rows(OldShRowCount).Copy _
Destination:= _
Sheets("NewSheet").Rows(NewShRowCount)
NewShRowCount = NewShRowCount + 1
End If
OldShRowCount = OldShRowCount + 1
Loop
End With

End Sub


"K" wrote:

Hi, I have data in coloumn A to coloumn E. (please see below)
A B C
D E
000 B10 G628 000B10G628 54
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 000B10 12
000 B10 000B10 13
000 B10 000B10 12
000 B10 000B10 12
in coloumn D i have Formula which is "=A1&B1&C1" as you can see above
and then I put
CONDITIONAL FORMATTING in coloumn D as well in which I put the Formula
which is
"=IF(AND(D2=D3,E2<E3),TRUE)" its mean that if two values in coloumn D
cells are equal but two values in coloumn E are not equal which are
against each other in same cells then its true and the Cell should
get Red colour. so when ever two values in coloumn D are equal but in
next coloumn E the two values are not equal cell get Red colour by
CONDITIONAL FORMATTING.I want MACRO which can copy only those rows in
which coloumn D cells have Red colour to next sheet. Please Note that
cells getting Red colours by CONDITIONAL FORMATTING and whole coloumn
D have CONDITIONAL FORMATTING. Some friend send me macro but it copy
all data to next sheet instead of just coping only those rows in which
coloumn D cells have Red colour by CONDITIONAL FORMATTING. Please if
anybody can help. Thanks


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default NEED MACRO FOR COLOUR BY CONDITIONAL FORMATTING

On Dec 16, 2:50 pm, Joel wrote:
from
NewShRowCount = 1
to
NewShRowCount = 2



"K" wrote:
Thanks Joel for replying. how can i amend your macro if i want macro
to copy data into next sheet from row 2 as i will be putting headings
in row 1. And also is there way i can get row copy from cell A to
cell F as with your macro its copying entire row.


Joel wrote:
Sub movedata()


OldShRowCount = 1
NewShRowCount = 1
With Sheets("OldSheet")
Do While .Range("D" & OldShRowCount) < ""
If (.Range("D" & OldShRowCount) = _
.Range("D" & (OldShRowCount + 1))) And _
(.Range("E" & OldShRowCount) < _
.Range("E" & (OldShRowCount + 1))) Then


.Rows(OldShRowCount).Copy _
Destination:= _
Sheets("NewSheet").Rows(NewShRowCount)
NewShRowCount = NewShRowCount + 1
End If
OldShRowCount = OldShRowCount + 1
Loop
End With


End Sub


"K" wrote:


Hi, I have data in coloumn A to coloumn E. (please see below)
A B C
D E
000 B10 G628 000B10G628 54
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 000B10 12
000 B10 000B10 13
000 B10 000B10 12
000 B10 000B10 12
in coloumn D i have Formula which is "=A1&B1&C1" as you can see above
and then I put
CONDITIONAL FORMATTING in coloumn D as well in which I put the Formula
which is
"=IF(AND(D2=D3,E2<E3),TRUE)" its mean that if two values in coloumn D
cells are equal but two values in coloumn E are not equal which are
against each other in same cells then its true and the Cell should
get Red colour. so when ever two values in coloumn D are equal but in
next coloumn E the two values are not equal cell get Red colour by
CONDITIONAL FORMATTING.I want MACRO which can copy only those rows in
which coloumn D cells have Red colour to next sheet. Please Note that
cells getting Red colours by CONDITIONAL FORMATTING and whole coloumn
D have CONDITIONAL FORMATTING. Some friend send me macro but it copy
all data to next sheet instead of just coping only those rows in which
coloumn D cells have Red colour by CONDITIONAL FORMATTING. Please if
anybody can help. Thanks- Hide quoted text -


- Show quoted text -


how can i get row lentgh for cell A to cell F to be copied into next
sheet as your macro coping entire row


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default NEED MACRO FOR COLOUR BY CONDITIONAL FORMATTING

Do you need to only copy certain columns? Your posting said rows, so I
copied rows. Below is modified code to put the last occupied column number
into newsheet

Sub movedata()

OldShRowCount = 1
NewShRowCount = 1
With Sheets("OldSheet")
Do While .Range("D" & OldShRowCount) < ""
If (.Range("D" & OldShRowCount) = _
.Range("D" & (OldShRowCount + 1))) And _
(.Range("E" & OldShRowCount) < _
.Range("E" & (OldShRowCount + 1))) Then

.Rows(OldShRowCount).Copy _
Destination:= _
Sheets("NewSheet").Rows(NewShRowCount)
LastColumn =
..Cells(OldShRowCount,columns.Count).end(xltoleft) .Column
Sheets("NewSheet"). Cells(NewShRowCount,LastColumn + 1) = _
LastColumn
NewShRowCount = NewShRowCount + 1
End If
OldShRowCount = OldShRowCount + 1
Loop
End With

End Sub


"K" wrote:

On Dec 16, 2:50 pm, Joel wrote:
from
NewShRowCount = 1
to
NewShRowCount = 2



"K" wrote:
Thanks Joel for replying. how can i amend your macro if i want macro
to copy data into next sheet from row 2 as i will be putting headings
in row 1. And also is there way i can get row copy from cell A to
cell F as with your macro its copying entire row.


Joel wrote:
Sub movedata()


OldShRowCount = 1
NewShRowCount = 1
With Sheets("OldSheet")
Do While .Range("D" & OldShRowCount) < ""
If (.Range("D" & OldShRowCount) = _
.Range("D" & (OldShRowCount + 1))) And _
(.Range("E" & OldShRowCount) < _
.Range("E" & (OldShRowCount + 1))) Then


.Rows(OldShRowCount).Copy _
Destination:= _
Sheets("NewSheet").Rows(NewShRowCount)
NewShRowCount = NewShRowCount + 1
End If
OldShRowCount = OldShRowCount + 1
Loop
End With


End Sub


"K" wrote:


Hi, I have data in coloumn A to coloumn E. (please see below)
A B C
D E
000 B10 G628 000B10G628 54
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 000B10 12
000 B10 000B10 13
000 B10 000B10 12
000 B10 000B10 12
in coloumn D i have Formula which is "=A1&B1&C1" as you can see above
and then I put
CONDITIONAL FORMATTING in coloumn D as well in which I put the Formula
which is
"=IF(AND(D2=D3,E2<E3),TRUE)" its mean that if two values in coloumn D
cells are equal but two values in coloumn E are not equal which are
against each other in same cells then its true and the Cell should
get Red colour. so when ever two values in coloumn D are equal but in
next coloumn E the two values are not equal cell get Red colour by
CONDITIONAL FORMATTING.I want MACRO which can copy only those rows in
which coloumn D cells have Red colour to next sheet. Please Note that
cells getting Red colours by CONDITIONAL FORMATTING and whole coloumn
D have CONDITIONAL FORMATTING. Some friend send me macro but it copy
all data to next sheet instead of just coping only those rows in which
coloumn D cells have Red colour by CONDITIONAL FORMATTING. Please if
anybody can help. Thanks- Hide quoted text -


- Show quoted text -


how can i get row lentgh for cell A to cell F to be copied into next
sheet as your macro coping entire row

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default NEED MACRO FOR COLOUR BY CONDITIONAL FORMATTING

thanks for modified code Joel just last thing in which line i should
put coloumn no. so it only copy that much into new sheet. i tried
putting coloumn no. but its not working.

Joel wrote:
Do you need to only copy certain columns? Your posting said rows, so I
copied rows. Below is modified code to put the last occupied column number
into newsheet

Sub movedata()

OldShRowCount = 1
NewShRowCount = 1
With Sheets("OldSheet")
Do While .Range("D" & OldShRowCount) < ""
If (.Range("D" & OldShRowCount) = _
.Range("D" & (OldShRowCount + 1))) And _
(.Range("E" & OldShRowCount) < _
.Range("E" & (OldShRowCount + 1))) Then

.Rows(OldShRowCount).Copy _
Destination:= _
Sheets("NewSheet").Rows(NewShRowCount)
LastColumn =
.Cells(OldShRowCount,columns.Count).end(xltoleft). Column
Sheets("NewSheet"). Cells(NewShRowCount,LastColumn + 1) = _
LastColumn
NewShRowCount = NewShRowCount + 1
End If
OldShRowCount = OldShRowCount + 1
Loop
End With

End Sub


"K" wrote:

On Dec 16, 2:50 pm, Joel wrote:
from
NewShRowCount = 1
to
NewShRowCount = 2



"K" wrote:
Thanks Joel for replying. how can i amend your macro if i want macro
to copy data into next sheet from row 2 as i will be putting headings
in row 1. And also is there way i can get row copy from cell A to
cell F as with your macro its copying entire row.

Joel wrote:
Sub movedata()

OldShRowCount = 1
NewShRowCount = 1
With Sheets("OldSheet")
Do While .Range("D" & OldShRowCount) < ""
If (.Range("D" & OldShRowCount) = _
.Range("D" & (OldShRowCount + 1))) And _
(.Range("E" & OldShRowCount) < _
.Range("E" & (OldShRowCount + 1))) Then

.Rows(OldShRowCount).Copy _
Destination:= _
Sheets("NewSheet").Rows(NewShRowCount)
NewShRowCount = NewShRowCount + 1
End If
OldShRowCount = OldShRowCount + 1
Loop
End With

End Sub

"K" wrote:

Hi, I have data in coloumn A to coloumn E. (please see below)
A B C
D E
000 B10 G628 000B10G628 54
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 000B10 12
000 B10 000B10 13
000 B10 000B10 12
000 B10 000B10 12
in coloumn D i have Formula which is "=A1&B1&C1" as you can see above
and then I put
CONDITIONAL FORMATTING in coloumn D as well in which I put the Formula
which is
"=IF(AND(D2=D3,E2<E3),TRUE)" its mean that if two values in coloumn D
cells are equal but two values in coloumn E are not equal which are
against each other in same cells then its true and the Cell should
get Red colour. so when ever two values in coloumn D are equal but in
next coloumn E the two values are not equal cell get Red colour by
CONDITIONAL FORMATTING.I want MACRO which can copy only those rows in
which coloumn D cells have Red colour to next sheet. Please Note that
cells getting Red colours by CONDITIONAL FORMATTING and whole coloumn
D have CONDITIONAL FORMATTING. Some friend send me macro but it copy
all data to next sheet instead of just coping only those rows in which
coloumn D cells have Red colour by CONDITIONAL FORMATTING. Please if
anybody can help. Thanks- Hide quoted text -

- Show quoted text -


how can i get row lentgh for cell A to cell F to be copied into next
sheet as your macro coping entire row

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default NEED MACRO FOR COLOUR BY CONDITIONAL FORMATTING

On Dec 16, 5:05 pm, K wrote:
thanks for modified code Joel just last thing in which line i should
put coloumn no. so it only copy that much into new sheet. i tried
putting coloumn no. but its not working.



Joel wrote:
Do you need to only copy certain columns? Your posting said rows, so I
copied rows. Below is modified code to put the last occupied column number
into newsheet


Sub movedata()


OldShRowCount = 1
NewShRowCount = 1
With Sheets("OldSheet")
Do While .Range("D" & OldShRowCount) < ""
If (.Range("D" & OldShRowCount) = _
.Range("D" & (OldShRowCount + 1))) And _
(.Range("E" & OldShRowCount) < _
.Range("E" & (OldShRowCount + 1))) Then


.Rows(OldShRowCount).Copy _
Destination:= _
Sheets("NewSheet").Rows(NewShRowCount)
LastColumn =
.Cells(OldShRowCount,columns.Count).end(xltoleft). Column
Sheets("NewSheet"). Cells(NewShRowCount,LastColumn + 1) = _
LastColumn
NewShRowCount = NewShRowCount + 1
End If
OldShRowCount = OldShRowCount + 1
Loop
End With


End Sub


"K" wrote:


On Dec 16, 2:50 pm, Joel wrote:
from
NewShRowCount = 1
to
NewShRowCount = 2


"K" wrote:
Thanks Joel for replying. how can i amend your macro if i want macro
to copy data into next sheet from row 2 as i will be putting headings
in row 1. And also is there way i can get row copy from cell A to
cell F as with your macro its copying entire row.


Joel wrote:
Sub movedata()


OldShRowCount = 1
NewShRowCount = 1
With Sheets("OldSheet")
Do While .Range("D" & OldShRowCount) < ""
If (.Range("D" & OldShRowCount) = _
.Range("D" & (OldShRowCount + 1))) And _
(.Range("E" & OldShRowCount) < _
.Range("E" & (OldShRowCount + 1))) Then


.Rows(OldShRowCount).Copy _
Destination:= _
Sheets("NewSheet").Rows(NewShRowCount)
NewShRowCount = NewShRowCount + 1
End If
OldShRowCount = OldShRowCount + 1
Loop
End With


End Sub


"K" wrote:


Hi, I have data in coloumn A to coloumn E. (please see below)
A B C
D E
000 B10 G628 000B10G628 54
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 000B10 12
000 B10 000B10 13
000 B10 000B10 12
000 B10 000B10 12
in coloumn D i have Formula which is "=A1&B1&C1" as you can see above
and then I put
CONDITIONAL FORMATTING in coloumn D as well in which I put the Formula
which is
"=IF(AND(D2=D3,E2<E3),TRUE)" its mean that if two values in coloumn D
cells are equal but two values in coloumn E are not equal which are
against each other in same cells then its true and the Cell should
get Red colour. so when ever two values in coloumn D are equal but in
next coloumn E the two values are not equal cell get Red colour by
CONDITIONAL FORMATTING.I want MACRO which can copy only those rows in
which coloumn D cells have Red colour to next sheet. Please Note that
cells getting Red colours by CONDITIONAL FORMATTING and whole coloumn
D have CONDITIONAL FORMATTING. Some friend send me macro but it copy
all data to next sheet instead of just coping only those rows in which
coloumn D cells have Red colour by CONDITIONAL FORMATTING. Please if
anybody can help. Thanks- Hide quoted text -


- Show quoted text -


how can i get row lentgh for cell A to cell F to be copied into next
sheet as your macro coping entire row- Hide quoted text -


- Show quoted text -


sorry i meant that with your code i can copy entire row but what if i
wan to copy row from cell A to cell F. your modified code is still
copying the entire row and putting numbers in last coloumn cells that
how many coloums it copied. i dont want to copy entire row just want
to copy from cell A to cell F which are 6 cells row. i hope you
understood
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default NEED MACRO FOR COLOUR BY CONDITIONAL FORMATTING

Sub movedata()

OldShRowCount = 1
NewShRowCount = 1
With Sheets("OldSheet")
Do While .Range("D" & OldShRowCount) < ""
If (.Range("D" & OldShRowCount) = _
.Range("D" & (OldShRowCount + 1))) And _
(.Range("E" & OldShRowCount) < _
.Range("E" & (OldShRowCount + 1))) Then

Set CopyRange = .Range("A" & OldShRowCount & _
":F" & OldShRowCount)
CopyRange.Copy Destination:= _
Sheets("NewSheet").Range("A" & NewShRowCount)
NewShRowCount = NewShRowCount + 1
End If
OldShRowCount = OldShRowCount + 1
Loop
End With

End Sub



"K" wrote:

On Dec 16, 5:05 pm, K wrote:
thanks for modified code Joel just last thing in which line i should
put coloumn no. so it only copy that much into new sheet. i tried
putting coloumn no. but its not working.



Joel wrote:
Do you need to only copy certain columns? Your posting said rows, so I
copied rows. Below is modified code to put the last occupied column number
into newsheet


Sub movedata()


OldShRowCount = 1
NewShRowCount = 1
With Sheets("OldSheet")
Do While .Range("D" & OldShRowCount) < ""
If (.Range("D" & OldShRowCount) = _
.Range("D" & (OldShRowCount + 1))) And _
(.Range("E" & OldShRowCount) < _
.Range("E" & (OldShRowCount + 1))) Then


.Rows(OldShRowCount).Copy _
Destination:= _
Sheets("NewSheet").Rows(NewShRowCount)
LastColumn =
.Cells(OldShRowCount,columns.Count).end(xltoleft). Column
Sheets("NewSheet"). Cells(NewShRowCount,LastColumn + 1) = _
LastColumn
NewShRowCount = NewShRowCount + 1
End If
OldShRowCount = OldShRowCount + 1
Loop
End With


End Sub


"K" wrote:


On Dec 16, 2:50 pm, Joel wrote:
from
NewShRowCount = 1
to
NewShRowCount = 2


"K" wrote:
Thanks Joel for replying. how can i amend your macro if i want macro
to copy data into next sheet from row 2 as i will be putting headings
in row 1. And also is there way i can get row copy from cell A to
cell F as with your macro its copying entire row.


Joel wrote:
Sub movedata()


OldShRowCount = 1
NewShRowCount = 1
With Sheets("OldSheet")
Do While .Range("D" & OldShRowCount) < ""
If (.Range("D" & OldShRowCount) = _
.Range("D" & (OldShRowCount + 1))) And _
(.Range("E" & OldShRowCount) < _
.Range("E" & (OldShRowCount + 1))) Then


.Rows(OldShRowCount).Copy _
Destination:= _
Sheets("NewSheet").Rows(NewShRowCount)
NewShRowCount = NewShRowCount + 1
End If
OldShRowCount = OldShRowCount + 1
Loop
End With


End Sub


"K" wrote:


Hi, I have data in coloumn A to coloumn E. (please see below)
A B C
D E
000 B10 G628 000B10G628 54
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 000B10 12
000 B10 000B10 13
000 B10 000B10 12
000 B10 000B10 12
in coloumn D i have Formula which is "=A1&B1&C1" as you can see above
and then I put
CONDITIONAL FORMATTING in coloumn D as well in which I put the Formula
which is
"=IF(AND(D2=D3,E2<E3),TRUE)" its mean that if two values in coloumn D
cells are equal but two values in coloumn E are not equal which are
against each other in same cells then its true and the Cell should
get Red colour. so when ever two values in coloumn D are equal but in
next coloumn E the two values are not equal cell get Red colour by
CONDITIONAL FORMATTING.I want MACRO which can copy only those rows in
which coloumn D cells have Red colour to next sheet. Please Note that
cells getting Red colours by CONDITIONAL FORMATTING and whole coloumn
D have CONDITIONAL FORMATTING. Some friend send me macro but it copy
all data to next sheet instead of just coping only those rows in which
coloumn D cells have Red colour by CONDITIONAL FORMATTING. Please if
anybody can help. Thanks- Hide quoted text -


- Show quoted text -


how can i get row lentgh for cell A to cell F to be copied into next
sheet as your macro coping entire row- Hide quoted text -


- Show quoted text -


sorry i meant that with your code i can copy entire row but what if i
wan to copy row from cell A to cell F. your modified code is still
copying the entire row and putting numbers in last coloumn cells that
how many coloums it copied. i dont want to copy entire row just want
to copy from cell A to cell F which are 6 cells row. i hope you
understood

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default NEED MACRO FOR COLOUR BY CONDITIONAL FORMATTING

On Dec 16, 5:30 pm, Joel wrote:
Sub movedata()

OldShRowCount = 1
NewShRowCount = 1
With Sheets("OldSheet")
Do While .Range("D" & OldShRowCount) < ""
If (.Range("D" & OldShRowCount) = _
.Range("D" & (OldShRowCount + 1))) And _
(.Range("E" & OldShRowCount) < _
.Range("E" & (OldShRowCount + 1))) Then

Set CopyRange = .Range("A" & OldShRowCount & _
":F" & OldShRowCount)
CopyRange.Copy Destination:= _
Sheets("NewSheet").Range("A" & NewShRowCount)
NewShRowCount = NewShRowCount + 1
End If
OldShRowCount = OldShRowCount + 1
Loop
End With

End Sub



"K" wrote:
On Dec 16, 5:05 pm, K wrote:
thanks for modified code Joel just last thing in which line i should
put coloumn no. so it only copy that much into new sheet. i tried
putting coloumn no. but its not working.


Joel wrote:
Do you need to only copy certain columns? Your posting said rows, so I
copied rows. Below is modified code to put the last occupied column number
into newsheet


Sub movedata()


OldShRowCount = 1
NewShRowCount = 1
With Sheets("OldSheet")
Do While .Range("D" & OldShRowCount) < ""
If (.Range("D" & OldShRowCount) = _
.Range("D" & (OldShRowCount + 1))) And _
(.Range("E" & OldShRowCount) < _
.Range("E" & (OldShRowCount + 1))) Then


.Rows(OldShRowCount).Copy _
Destination:= _
Sheets("NewSheet").Rows(NewShRowCount)
LastColumn =
.Cells(OldShRowCount,columns.Count).end(xltoleft). Column
Sheets("NewSheet"). Cells(NewShRowCount,LastColumn + 1) = _
LastColumn
NewShRowCount = NewShRowCount + 1
End If
OldShRowCount = OldShRowCount + 1
Loop
End With


End Sub


"K" wrote:


On Dec 16, 2:50 pm, Joel wrote:
from
NewShRowCount = 1
to
NewShRowCount = 2


"K" wrote:
Thanks Joel for replying. how can i amend your macro if i want macro
to copy data into next sheet from row 2 as i will be putting headings
in row 1. And also is there way i can get row copy from cell A to
cell F as with your macro its copying entire row.


Joel wrote:
Sub movedata()


OldShRowCount = 1
NewShRowCount = 1
With Sheets("OldSheet")
Do While .Range("D" & OldShRowCount) < ""
If (.Range("D" & OldShRowCount) = _
.Range("D" & (OldShRowCount + 1))) And _
(.Range("E" & OldShRowCount) < _
.Range("E" & (OldShRowCount + 1))) Then


.Rows(OldShRowCount).Copy _
Destination:= _
Sheets("NewSheet").Rows(NewShRowCount)
NewShRowCount = NewShRowCount + 1
End If
OldShRowCount = OldShRowCount + 1
Loop
End With


End Sub


"K" wrote:


Hi, I have data in coloumn A to coloumn E. (please see below)
A B C
D E
000 B10 G628 000B10G628 54
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 G628 000B10G628 53
000 B10 000B10 12
000 B10 000B10 13
000 B10 000B10 12
000 B10 000B10 12
in coloumn D i have Formula which is "=A1&B1&C1" as you can see above
and then I put
CONDITIONAL FORMATTING in coloumn D as well in which I put the Formula
which is
"=IF(AND(D2=D3,E2<E3),TRUE)" its mean that if two values in coloumn D
cells are equal but two values in coloumn E are not equal which are
against each other in same cells then its true and the Cell should
get Red colour. so when ever two values in coloumn D are equal but in
next coloumn E the two values are not equal cell get Red colour by
CONDITIONAL FORMATTING.I want MACRO which can copy only those rows in
which coloumn D cells have Red colour to next sheet. Please Note that
cells getting Red colours by CONDITIONAL FORMATTING and whole coloumn
D have CONDITIONAL FORMATTING. Some friend send me macro but it copy
all data to next sheet instead of just coping only those rows in which
coloumn D cells have Red colour by CONDITIONAL FORMATTING. Please if
anybody can help. Thanks- Hide quoted text -


- Show quoted text -


how can i get row lentgh for cell A to cell F to be copied into next
sheet as your macro coping entire row- Hide quoted text -


- Show quoted text -


sorry i meant that with your code i can copy entire row but what if i
wan to copy row from cell A to cell F. your modified code is still
copying the entire row and putting numbers in last coloumn cells that
how many coloums it copied. i dont want to copy entire row just want
to copy from cell A to cell F which are 6 cells row. i hope you
understood- Hide quoted text -


- Show quoted text -


Thanks . This work perfectly fine you are genius
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
Conditional Formatting - Row colour Steven Excel Discussion (Misc queries) 5 May 6th 09 06:14 PM
Conditional formatting - flashing colour Michael Excel Discussion (Misc queries) 1 November 24th 06 10:37 AM
change tab colour when using conditional formatting in a cell julie s Excel Worksheet Functions 6 October 23rd 06 09:13 PM
Interior Cell Colour - Conditional Formatting michael.a7[_4_] Excel Programming 3 April 24th 06 08:21 AM
Conditional formatting: Colour coding Kelly Excel Discussion (Misc queries) 4 January 18th 06 11:11 AM


All times are GMT +1. The time now is 08:47 PM.

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"