PDA

View Full Version : [SOLVED] Problem with an if code



Ismael
02-23-2005, 08:41 AM
Hi again to you guys,

I'm starting now with VBA, so my doubt can be very simple.

I Have made a code of an IF then ElseIf.... (you can see the code in the attach file)

But I only refer to one cell, as you can see in the code I said that if B4="TP" then return N4 = A4, but now I want to this:

If B4 = "TP" then return N4:Y4 = A4:O4

but I don't now how I can make this reference in VBA.:banghead:

So if any of you guys can give a help I appreciate.

Thanks

Best Regards,

Ismael

mvidas
02-23-2005, 09:20 AM
Hi Ismael,

This won't be tough, and we can condense your code quite a bit, but I'm curious how you want N4:Y4=A4:O4 (first is 12 cells, second is 15 cells), perhaps you meant A4:L4 instead?

If you did, you could use the following code to do what you need:

Select Case Range("B4")
Case "AZ", "BA", "LH", "LK", "S4", "LX", "IB", "AF", "TV"
Range("A4:L4").Copy Range("N4:Y4")
End Select

And if you plan on looping through the cells in column B, you could use:

Dim CLL As Range
For Each CLL In Range("B4", Range("B65536").End(xlUp)).Cells
Select Case CLL.Text
Case "AZ", "BA", "LH", "LK", "S4", "LX", "IB", "AF", "TV"
Range(Cells(CLL.Row, 1), Cells(CLL.Row, 12)).Copy Cells(CLL.Row, 14)
End Select
Next CLL

Matt

Ismael
02-23-2005, 09:39 AM
Hi Matt,

My mistake what I want to say is A4:L4.

I will use the second code that you have send me.

Many thanks

:beerchug:

best regards,

Ismael