#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default 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
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
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
Excel 2007 macros - how to merge 5 macros together into one Sue Excel Discussion (Misc queries) 1 April 16th 08 08:36 PM
Training: More on how to use macros in Excel: Recording Macros ToriT Excel Worksheet Functions 2 February 10th 06 07:05 PM
Macro Size Limit / open macros with macros? andycharger[_7_] Excel Programming 6 February 13th 04 02:00 PM
Macros not appearing in the Tools Macro Macros list hglamy[_2_] Excel Programming 5 October 24th 03 09:10 AM
Suppress the Disable Macros / Enable Macros Dialog Shoji Karai Excel Programming 5 September 24th 03 03:10 AM


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