Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Make Alignment options under format cells available as shortcut | Excel Discussion (Misc queries) | |||
Help with macro looping and color query function | Excel Discussion (Misc queries) | |||
Playing a macro from another workbook | Excel Discussion (Misc queries) | |||
Date macro | Excel Discussion (Misc queries) | |||
Macro and If Statement | Excel Discussion (Misc queries) |