Checking the cell

GetMad

New Member
Joined
May 9, 2011
Messages
8
Hello, i am new one in here, need some help.

Well basically, this is what i need to write in VBA. Please help me with this.

If cell[A13] is filled
Then copy cell[A13] to cell[E44]
Else: 'Do nothing


How can i write it down, but in VBA language?

Thanks a lot.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Welcome to the MrExcel board!

Would this do what you want?
Code:
Range("E44").Value = Range("A13").Value

Edit: It won't if E44 might already contain a value - not sure what your circumstances are. :)
 
Upvote 0
Thank you, for your fast reply, Peter! :)

I will try to describe my situation a bit better.

I have a Cell, which may be or may not be filled, with number or with letter, it does not matter. So i need VBA to check this cell, if it is filled or it is not, so if the cell is filled with something, than copy that cells value to other cell.

Is it possible to do that?

Thank you for help!
 
Upvote 0
Did you try my code?

It copies the value from A13 to E44. It does not check if A13 contains anything. In that sense it does not do what you asked. However, my reasoning was that if A13 doesn't contain anything then copying 'nothing' to E44 wouldn't be a problem - unless E44 may already contain some value which would get over-written. You didn't say if E44 may already contain some data before the code is run?
 
Upvote 0
Yes, sorry.

I have tried you code and it does work. And no cell E44 does not contain anything, it is empty. So there is no problems thank you.

But i have to force VBA to check those cells, if they are filled, because only if they are filled, VBA should continue my cycle.

So i don't know how to make VBA to check that cell, if there is something written in it or not. Can you help me with it please?

i tried check it for number like this:

Sub LK()

If Range("B17").Value = IsNumeric(.Value) Then
Range("W15").Value = Range("B17").Value
Else: 'do nothing
End If

End Sub

But it does not work.

Thank you, i really appreciate your help.
 
Upvote 0
But i have to force VBA to check those cells, if they are filled, because only if they are filled, VBA should continue my cycle.
I'm not sure what that means. You are also now referring to cells in plural whereas to start with we were just looking at one cell.

Could you try to explain again in different words and/or give examples of exactly what you are trying to achieve?

Do you mean you want the code to automatically run as soon as something is entered into the first cell?

(It would also help if you kept your cell references the same - at least until you get some working code. )
 
Upvote 0
Yes, i am so sorry for giving a lot of misleading information.

I will give you whole picture of what i am trying to achieve. Before i tried to start just from a small part of what i am trying to achieve.

I have a large table, in which are different numbers and text.
And next to that table, i must create a Decision tree.
So my idea was:
I will make a code(but i do not have a knowledge to do that), which will check cell, for example, B17, and if that cell is filled with something, whether it is number or text, it will draw a specific shape and copy the value of cell B17 to cell W15, and continues to check another cells, if B17 is empty then it skips drawing specific shape and copying the content of B17 to W15, and just starts to check another cells.

Please see the picture. Please, if i did not gave you clearer information ask me more, because i really need help. Thank you a lot. :)

Untitled42423.jpg
 
Upvote 0
Most of that image is pretty much impossible for me to read. In any case you will get much more help if you can post a small screen shot directly in your post. My signature block below contains 3 methods for posting small screen shots. Test them in the Test Here forum. That way, if something goes wrong, you won’t be messing up a main forum.

The advantages are that potential helpers do not have to go to another page to see your sample (many will just skip your post) and your data can then be copied from the forum to a worksheet to test with. This is not possible with your linked image.

Anyway, see if a structure something like this is any use.

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> foo()<br>    <SPAN style="color:#00007F">Dim</SPAN> r <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, LastRow <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <br>    Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br>    LastRow = Range("B" & Rows.Count).End(xlUp).Row<br>    <SPAN style="color:#00007F">For</SPAN> r = 17 <SPAN style="color:#00007F">To</SPAN> LastRow <SPAN style="color:#00007F">Step</SPAN> 28<br>        <SPAN style="color:#00007F">If</SPAN> Len(Cells(r, "B").Value) > 0 <SPAN style="color:#00007F">Then</SPAN><br>            Cells(r - 2, "W").Value = Cells(r, "B").Value<br>            <br>            <SPAN style="color:#007F00">'Do your drawing stuff here</SPAN><br>            <br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>    <SPAN style="color:#00007F">Next</SPAN> r<br>    Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0
I will take that information in mind, and will post my pictures in future correct.

And thank you for the code, it is working.

But this code is made for cells in whole Row, with step of 28, as i understood, but i need a code only for 1 cell, because each cell will have a different shape. I tried to modify it only for 1 cell, but it did not work out for me, can you please post the code for 1 cell?


Sorry for bothering, and thank you once again, Peter.
 
Upvote 0
.. but i need a code only for 1 cell, ..
That seems to contradict your earlier statement:
.. and continues to check another cells, ..


Is there a fixed shape for each cell that you have to check?

- If 'No', tell us more about the shapes and how you draw them and how you decide what shape to draw.

- If 'Yes', perhaps you could add to the code like this?

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> foo()<br>    <SPAN style="color:#00007F">Dim</SPAN> r <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, LastRow <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <br>    Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br>    LastRow = Range("B" & Rows.Count).End(xlUp).Row<br>    <SPAN style="color:#00007F">For</SPAN> r = 17 <SPAN style="color:#00007F">To</SPAN> LastRow <SPAN style="color:#00007F">Step</SPAN> 28<br>        <SPAN style="color:#00007F">If</SPAN> Len(Cells(r, "B").Value) > 0 <SPAN style="color:#00007F">Then</SPAN><br>            Cells(r - 2, "W").Value = Cells(r, "B").Value<br>            <SPAN style="color:#00007F">Select</SPAN> <SPAN style="color:#00007F">Case</SPAN> r<br>                <SPAN style="color:#00007F">Case</SPAN> 17<br>                    <SPAN style="color:#007F00">'Drawing code here</SPAN><br>                <SPAN style="color:#00007F">Case</SPAN> 45<br>                    <SPAN style="color:#007F00">'Different drawing code here</SPAN><br>                <SPAN style="color:#00007F">Case</SPAN> 73<br>                    <SPAN style="color:#007F00">'Yet another drawing code here</SPAN><br>                    <br>                    <SPAN style="color:#007F00">'<- Add more 'Case' statements if required</SPAN><br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Select</SPAN><br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>    <SPAN style="color:#00007F">Next</SPAN> r<br>    Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,626
Members
452,933
Latest member
patv

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