Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
CN
 
Posts: n/a
Default writing macro

I have 7 collumns:
A B C D E H G
b Ptt F
b Ptt F
bb dd Ptt T
a b d Dgg T
I have 3 condition to work with:
* If column D= "Ptt" & E = "F" then copy col "B" the same row to col "H"
* If column D= "Ptt" & E = "T" then copy col "C" the same row to col "G"
* If column D= "Dgg" & E = "T" then copy col "a" the same row to col "G"

Here I have so far:
Sub ButtonCopy()
Range("B2:F20").Select
Do Until ActiveCell = ""
If ActiveCell = "" Then End
ActiveCell.Select
'ActiveCell.EntireRow.Select
If ActiveCell = "F" Then
With Selection.Interior
..ColorIndex = 6
..Pattern = xlSolid
..PatternColorIndex = xlAutomatic
Range("B2:B20").Select
Selection.Font.ColorIndex = 9
Selection.Copy
'Paste results
ActiveSheet.Paste
Range("H2:H20").Select
ActiveSheet.Paste
Selection.Font.ColorIndex = 9
End With
End If
ActiveCell.Offset(1, 0).Activate
End Sub
I Think I have couple issues on this, please help,
my question is how can I copy in the same row instead copy as range?
and can I make two condition instead of one, this is my first time writting
this, any advise will be very helpful to me.
Thanks in advance,
  #2   Report Post  
Bernie Deitrick
 
Posts: n/a
Default

CN,

Sub ButtonCopy2()
Dim i As Integer

For i = 2 To 20
If Range("D" & i).Value = "Ptt" And _
Range("E" & i).Value = "F" Then
Range("B" & i).Copy Range("H" & i)
End If
If Range("D" & i).Value = "Ptt" And _
Range("E" & i).Value = "T" Then
Range("C" & i).Copy Range("G" & i)
End If
If Range("D" & i).Value = "Dgg" And _
Range("E" & i).Value = "T" Then
Range("A" & i).Copy Range("G" & i)
End If
Next i
End Sub

HTH,
Bernie
MS Excel MVP


"CN" wrote in message
...
I have 7 collumns:
A B C D E H G
b Ptt F
b Ptt F
bb dd Ptt T
a b d Dgg T
I have 3 condition to work with:
* If column D= "Ptt" & E = "F" then copy col "B" the same row to col "H"
* If column D= "Ptt" & E = "T" then copy col "C" the same row to col "G"
* If column D= "Dgg" & E = "T" then copy col "a" the same row to col "G"

Here I have so far:
Sub ButtonCopy()
Range("B2:F20").Select
Do Until ActiveCell = ""
If ActiveCell = "" Then End
ActiveCell.Select
'ActiveCell.EntireRow.Select
If ActiveCell = "F" Then
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
Range("B2:B20").Select
Selection.Font.ColorIndex = 9
Selection.Copy
'Paste results
ActiveSheet.Paste
Range("H2:H20").Select
ActiveSheet.Paste
Selection.Font.ColorIndex = 9
End With
End If
ActiveCell.Offset(1, 0).Activate
End Sub
I Think I have couple issues on this, please help,
my question is how can I copy in the same row instead copy as range?
and can I make two condition instead of one, this is my first time writting
this, any advise will be very helpful to me.
Thanks in advance,



  #3   Report Post  
CN
 
Posts: n/a
Default

Thank you very much for helping, it works great!
..
CN

"Bernie Deitrick" wrote:

CN,

Sub ButtonCopy2()
Dim i As Integer

For i = 2 To 20
If Range("D" & i).Value = "Ptt" And _
Range("E" & i).Value = "F" Then
Range("B" & i).Copy Range("H" & i)
End If
If Range("D" & i).Value = "Ptt" And _
Range("E" & i).Value = "T" Then
Range("C" & i).Copy Range("G" & i)
End If
If Range("D" & i).Value = "Dgg" And _
Range("E" & i).Value = "T" Then
Range("A" & i).Copy Range("G" & i)
End If
Next i
End Sub

HTH,
Bernie
MS Excel MVP


"CN" wrote in message
...
I have 7 collumns:
A B C D E H G
b Ptt F
b Ptt F
bb dd Ptt T
a b d Dgg T
I have 3 condition to work with:
* If column D= "Ptt" & E = "F" then copy col "B" the same row to col "H"
* If column D= "Ptt" & E = "T" then copy col "C" the same row to col "G"
* If column D= "Dgg" & E = "T" then copy col "a" the same row to col "G"

Here I have so far:
Sub ButtonCopy()
Range("B2:F20").Select
Do Until ActiveCell = ""
If ActiveCell = "" Then End
ActiveCell.Select
'ActiveCell.EntireRow.Select
If ActiveCell = "F" Then
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
Range("B2:B20").Select
Selection.Font.ColorIndex = 9
Selection.Copy
'Paste results
ActiveSheet.Paste
Range("H2:H20").Select
ActiveSheet.Paste
Selection.Font.ColorIndex = 9
End With
End If
ActiveCell.Offset(1, 0).Activate
End Sub
I Think I have couple issues on this, please help,
my question is how can I copy in the same row instead copy as range?
and can I make two condition instead of one, this is my first time writting
this, any advise will be very helpful to me.
Thanks in advance,




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
Make Alignment options under format cells available as shortcut dforrest Excel Discussion (Misc queries) 1 July 14th 05 10:58 PM
Help with macro looping and color query function kevinm Excel Discussion (Misc queries) 10 May 26th 05 01:25 AM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM


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