?
Solved

Need help with an excel formula

Posted on 2014-03-05
11
Medium Priority
?
281 Views
Last Modified: 2014-03-09
I need a excel formula to move data from one cell to another cell with the following condition.

If A1 = NULL then move B1 to A1 else both remain the same. The same for B1 and C1

Sample:
sample
Notice that row 7 was fine and no data moving was needed there.
0
Comment
Question by:Gerhardpet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
11 Comments
 
LVL 10

Expert Comment

by:etech0
ID: 39907288
Sounds like you would be better off with a macro. Something like:
Sub macro()
For x = 2 To ActiveSheet.UsedRange.Rows.Count
    If Cells(x, 1).Value = "" Then
        Cells(x, 1).Value = Cells(x, 2).Value
        Cells(x, 2).Value = Cells(x, 3).Value
        Cells(x, 3).Value = ""
    End If
Next
    
End Sub

Open in new window


Note: you would have to put that into a blank module in the VB Editor.
0
 
LVL 15

Expert Comment

by:DrTribos
ID: 39907307
I am not sure if what you want is possible with formulas alone, at least not on the same sheet.  

Reason is that the input for the formula changes so I think you end up with a circular type of reference.

Would you be happy to have your original sheet as raw data and a 2nd sheet as corrected data?

Other wise you can definitely do it with a VBA macro Or by processing the data to additional rows and then manually deleting after copying and pasting 'without formulas'.

HTH
0
 
LVL 1

Author Comment

by:Gerhardpet
ID: 39907309
I have no clue how to use a macro. How would I use it or set it up?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 10

Expert Comment

by:etech0
ID: 39907333
Press alt-F11 to open the VB Editor.

Click Insert > Module.

Paste the code above into the blank window that opens. Note: You should probably change the word "macro" in the code to something that describes what we're doing. EG: FixAddresses.

How to run the macro would depend on what version of excel you're using. You can tell us what version for more specific instructions, or google "run macro in excel 2010" or whatever version it is.

Good luck!
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 2000 total points
ID: 39907351
Without a macro:

Select the column A data........In this case......A2:A4
Press F5
Click on special
Select Blanks
OK
Now right-click on one of the selected blank cells
Select delete
Select Shift cells left
Click OK
0
 
LVL 1

Author Comment

by:Gerhardpet
ID: 39907357
I'm using Excel 2010
0
 
LVL 13

Expert Comment

by:Santosh Gupta
ID: 39907375
you can also try this.... it will move all cell to left in case of blank cell.

Sub Foo()
Lr = Range("A" & Rows.Count).End(xlUp).Row
Set Rng = Range("A1:A" & Lr)
For Each C In Rng
    If C = "" Then
    C.Delete Shift:=xlToLeft
    End If
Next C
End Sub
0
 
LVL 1

Author Closing Comment

by:Gerhardpet
ID: 39907381
Syed,
Your solution worked perfect for what I wanted. Thanks for your help!
0
 
LVL 15

Expert Comment

by:DrTribos
ID: 39907400
Syed - I'd have mucked around with formulas for an hour or macros for a minute to sort this, learnt something simple and new :-)  - thanks +1
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39907512
Be my guest.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question