Solved

Need help with an excel formula

Posted on 2014-03-05
11
278 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

749 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