vba question

flynpat46

New Member
Joined
Sep 24, 2018
Messages
11
Hi,
Please help..
I am having trouble finding right code for my project. There are three rows. The third rows is empty. I need vba to evaluate B1, if less than 0, put an X in C1. Repeat on down until there isn't a value in column B.
[TABLE="width: 98"]
<colgroup><col width="44" style="width: 33pt; mso-width-source: userset; mso-width-alt: 1609;"> <col width="43" style="width: 32pt; mso-width-source: userset; mso-width-alt: 1572;"> <col width="44" style="width: 33pt; mso-width-source: userset; mso-width-alt: 1609;"> <tbody>[TR]
[TD="width: 44, bgcolor: transparent"]1[/TD]
[TD="width: 43, bgcolor: transparent"]75[/TD]
[TD="width: 44, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]2[/TD]
[TD="bgcolor: transparent"]15[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]3[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]4[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]5[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]6[/TD]
[TD="bgcolor: transparent"]3[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]7[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]8[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]9[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]10[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]11[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]12[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]13[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]14[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]15[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]16[/TD]
[TD="bgcolor: transparent"]16[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]17[/TD]
[TD="bgcolor: transparent"]84[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]18[/TD]
[TD="bgcolor: transparent"]185[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
</tbody>[/TABLE]
 
Hello,
I guess I should have just did this instead. In column E, starting at E4, if 0, then F4 will have an X.
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hello,
I wanted to put the full sheet up with X's to the right of the cell with the zero. I believe that we will need a loop to evaluate starting at E4 down until there isn't a value in the E column. Then do the same for columns G,I,K,M,O,and Q.
Thank you for you help and patiences.
CONTAINER # 31 S/T # S/T # S/T # S/T # S/T # S/T # S/T #
CONT. M8076L M8077C M8078G M8079A M8080F TOTAL
ITEM# PART # DESCRIPTION TOTAL TX SHIP MS SHIP CA SHIP GA SHIP AZ SHIP FL SHIP Hou SHIP LEFT
1 PART # DESCRIPTION 500 75 350 0 X 0 X 75 0 X 0 X 0
2 PART # DESCRIPTION 100 15 30 25 0 X 30 0 X 0 X 0
3 PART # DESCRIPTION 20 0 X 10 0 X 0 X 10 0 X 0 X 0
4 PART # DESCRIPTION 40 0 X 0 X 0 X 0 X 40 0 X 0 X 0
5 PART # DESCRIPTION 25 0 X 0 X 0 X 0 X 25 0 X 0 X 0
6 PART # DESCRIPTION 26 3 2 2 2 15 2 0 X 0
7 PART # DESCRIPTION 162 0 X 162 0 X 0 X 0 X 0 X 0 X 0
8 PART # DESCRIPTION 76 0 X 51 0 X 0 X 15 10 0 X 0
9 PART # DESCRIPTION 69 0 X 0 X 0 X 0 X 69 0 X 0 X 0
10 PART # DESCRIPTION 103 0 X 32 16 25 30 0 X 0 X 0
11 PART # DESCRIPTION 6 0 X 6 0 X 0 X 0 X 0 X 0 X 0
12 PART # DESCRIPTION 23 0 X 0 X 0 X 0 X 10 13 0 X 0
13 PART # DESCRIPTION 88 0 X 88 0 X 0 X 0 X 0 X 0 X 0
14 PART # DESCRIPTION 10 0 X 10 0 X 0 X 0 X 0 X 0 X 0
15 PART # DESCRIPTION 25 0 X 25 0 X 0 X 0 X 0 X 0 X 0
16 PART # DESCRIPTION 16 16 0 X 0 X 0 X 0 X 0 X 0 X 0
17 PART # DESCRIPTION 84 84 0 X 0 X 0 X 0 X 0 X 0 X 0
18 PART # DESCRIPTION 185 185 0 X 0 X 0 X 0 X 0 X 0 X 0
 
Upvote 0
Try
Code:
Sub AddX()
   Dim i As Long
   For i = 5 To 17 Step 2
      With Range(Cells(4, i + 1), Cells(Rows.Count, i).End(xlUp).Offset(, 1))
         .Value = Evaluate(Replace("if(@=0,""X"","""")", "@", .Offset(, -1).Address))
      End With
   Next i
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top