Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macros
I'm trying to write a macro that will cut and paste cells in the same row to different columns in the same row based on the cell value in the test cell in a range of cells. If the value of the test cell is 0 the macro will perform the functions programmed. If the value in the test cell = 0 the macro will go to the next cell and continue through the entire range
|
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macros
Hi,
There's at least two different ways to write this: Sub SimpleMacro1() Dim Cel As Variant For Each Cel In Range("D1:D21") If Cel 0 Then Cel.Offset(0, 3).Value = Cel.Offset(0, 1).Value ElseIf Cel = 0 Then Cel.Offset(0, 3).Value = Cel.Offset(0, 2).Value End If Next Cel End Sub Sub SimpleMacro2() Dim i As Integer For i = 1 To 21 If Cells(i, 4).Value 0 Then Cells(i, 7).Value = Cells(i, 5).Value ElseIf Cells(i, 4).Value = 0 Then Cells(i, 7).Value = Cells(i, 6).Value End If Next i End Sub HTH - Rick -----Original Message----- I'm trying to write a macro that will cut and paste cells in the same row to different columns in the same row based on the cell value in the test cell in a range of cells. If the value of the test cell is 0 the macro will perform the functions programmed. If the value in the test cell = 0 the macro will go to the next cell and continue through the entire range . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macros
for each c in selection
if c0 then c.cut c.offset(0,5) next c -- Don Guillett SalesAid Software "Unday" wrote in message ... I'm trying to write a macro that will cut and paste cells in the same row to different columns in the same row based on the cell value in the test cell in a range of cells. If the value of the test cell is 0 the macro will perform the functions programmed. If the value in the test cell = 0 the macro will go to the next cell and continue through the entire range |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macros
Rick
If you're out there, thanks. Your solution works like a charm Regards Unda ----- Rick wrote: ---- Hi There's at least two different ways to write this Sub SimpleMacro1( Dim Cel As Varian For Each Cel In Range("D1:D21" If Cel 0 The Cel.Offset(0, 3).Value = Cel.Offset(0, 1).Valu ElseIf Cel = 0 The Cel.Offset(0, 3).Value = Cel.Offset(0, 2).Valu End I Next Ce End Su Sub SimpleMacro2( Dim i As Intege For i = 1 To 2 If Cells(i, 4).Value 0 The Cells(i, 7).Value = Cells(i, 5).Valu ElseIf Cells(i, 4).Value = 0 The Cells(i, 7).Value = Cells(i, 6).Valu End I Next End Su HTH - Ric -----Original Message---- I'm trying to write a macro that will cut and paste cells in the same row to different columns in the same row based on the cell value in the test cell in a range of cells. If the value of the test cell is 0 the macro will perform the functions programmed. If the value in the test cell = 0 the macro will go to the next cell and continue through the entire rang |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel 2007 macros - how to merge 5 macros together into one | Excel Discussion (Misc queries) | |||
Training: More on how to use macros in Excel: Recording Macros | Excel Worksheet Functions | |||
Macro Size Limit / open macros with macros? | Excel Programming | |||
Macros not appearing in the Tools Macro Macros list | Excel Programming | |||
Suppress the Disable Macros / Enable Macros Dialog | Excel Programming |