VBA insert the next value

bluefeather8989

Active Member
Joined
Nov 20, 2009
Messages
325
Office Version
  1. 365
Platform
  1. Windows
In cells R14:R20 I have numbers from 0-6. each number will show based on a formula. in cell N4 is a number from 0-6 inserted by vba. what I need is VBA to search the range R14:R20 for the number that's in cell N4 then search next number and insert that number into N4.

Example:
if R13=1 or 2 do nothing

N4=0
the next number in the range (R14:R20) is 3. N4 value will change to 3

If N4 value is 6
the next number in the range (R14:R20) is 0. N4 value will change to 0

TV Shows.xlsm
OPQR
133
14Monday220
15Tuesday  
16Wednesday  
17Thursday223
18Friday  
19Saturday  
20Sunday226
List
Cell Formulas
RangeFormula
Q13Q13=COUNT(Q14:Q20)
Q14Q14=IF(COUNTIF(U:U,"Monday")>1,COUNTIF(U:U,"Monday"),"0")
R14R14=IF(P14>1,0,"")
Q15Q15=IF(COUNTIF(U:U,"Tuesday")>1,COUNTIF(U:U,"Tuesday"),"")
R15R15=IF(P15>1,1,"")
Q16Q16=IF(COUNTIF(U:U,"Wednesday")>1,COUNTIF(U:U,"Wednesday"),"")
R16R16=IF(P16>1,2,"")
Q17Q17=IF(COUNTIF(U:U,"Thursday")>1,COUNTIF(U:U,"Thursday"),"")
R17R17=IF(P17>1,3,"")
Q18Q18=IF(COUNTIF(U:U,"Frinday")>1,COUNTIF(U:U,"Frinday"),"")
R18R18=IF(P18>1,5,"")
Q19Q19=IF(COUNTIF(U:U,"Saturday")>1,COUNTIF(U:U,"Saturday"),"")
R19:R20R19=IF(P19>1,6,"")
Q20Q20=IF(COUNTIF(U:U,"Sunday")>1,COUNTIF(U:U,"Sunday"),"")
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,214,968
Messages
6,122,506
Members
449,089
Latest member
RandomExceller01

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