VBA code to return value in specific Column based on criteria

SamCha

New Member
Joined
Nov 23, 2020
Messages
28
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

Please can you help me with a code for the below:

Excel Formula:
[TABLE]
[TR]
[TD]=IF(H5>0,IF('Sheet 2'!M2>0,'Sheet 2'!M2, Sheet2'!L2),"")[/TD]
[/TR]
[/TABLE]

The return value is in Sheet 1 in Column K. If there is a value in Sheet 1 in Column H5 (the column size varies staring from Row 5) , then return the result from Sheet 2 from Column M (data starts from Row 2) or else return column L. The cell is formatted as text as there are leading zeros (number of zeros in each number is not consistent), so cant convert it to general or apply formula.

Thanks in advance
 

Some videos you may like

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

maabadi

Well-known Member
Joined
Oct 22, 2012
Messages
1,617
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Replace M2 with M2*1 and So on.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,457
Messages
5,624,853
Members
416,063
Latest member
chaulon199

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
Top