Excel if statement MB/KB to GB

AsiekG 41 Reputation points
2023-06-01T12:50:19.59+00:00

Hi,

See table below:

| Value | Type |

| 21 | MB |

| 916 | MB |

| 1.91 | GB |

| 1.02 | GB |

| 6 | MB |

| 659 | kB |

| 101 | MB |

| 47 | MB |

| 487 | MB |

| 1.46 | GB |

| 829 | MB |

| 556 | kB |

| 211 | MB |

| 291 | MB |

| 836 | MB |

| 796 | MB |

| 1.39 | GB |

| 841 | MB |

| 784 | kB |

| 16 | MB |

| 18 | MB |

| 6 | MB |

| 1.39 | GB |

| 288 | MB |

| 128 | MB |

| 246 | MB |

| 232 | MB |

| 18 | MB |

| 1.52 | GB |

| 1.49 | GB |

I am trying to convert each MB and KB to GB. Now this is only 30 cells, so that could be done by doing them one by one.. But I need to do it for at least 300 cells more.. What I want to achieve is that if a cell contains a MB or KB value, convert it to a GB value. I tried different search, IF, OR, ISNUMBER combinations but unfortunately I'm not really an Excel expert.. Can anyone help me with this?

Thank you.

Microsoft 365 and Office | Excel | For business | Windows
{count} votes

2 answers

Sort by: Most helpful
  1. Tanay Prasad 2,250 Reputation points
    2023-06-02T06:28:31.3766667+00:00

    Hi,

    You can use a combination of formulas in Excel to convert the values in MB and kB to GB:

    • Assuming your values are in the "Value" column and the corresponding types are in the "Type" column, you can add a new column (let's say it's column C) to calculate the converted values.
    • In cell C2, enter the following formula:
    =IF(B2="MB",A2/1024,IF(B2="kB",A2/1024/1024,A2))
    
    • Drag the formula down to apply it to the rest of the cells in column C.
    • Format the cells in column C as desired to display the values in GB. Select the cells, right-click, choose "Format Cells," go to the "Number" tab, and select "Gigabyte (GB)" as the format.

    Now, the values in column C will represent the converted values in GB. If a cell in the "Type" column contains "MB," it will be divided by 1024 to convert it to GB. If it contains "kB," it will be divided by 1024 twice (1024 * 1024) to convert it to GB. Otherwise, the value remains the same.

    Note: Make sure to use the correct cell references based on your specific data layout. If your data is in a different range or columns, adjust the formulas accordingly.

    Best Regards.

    0 comments No comments

  2. AllenXu-MSFT 24,951 Reputation points Moderator
    2023-06-02T07:04:28.1566667+00:00

    Hi @AsiekG,

    Add a new column to the table, and use the formula like below:

    =IFS(B2="MB",A2/1024,B2="KB",A2/1048576,TRUE,A2)

    FORMULA

    Copy the values of new column and paste to the "Value" column.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.