PDA

View Full Version : [SOLVED:] HLOOKUP not in all columns or something else?



danovkos
07-08-2015, 12:33 AM
Hi,
pls. i have for me very hard problem.

I have e.g. about 20 columns. In this columns are amount. I want to search for numbers in columns but not in all columns and only in each third column.
With other words. I have columns KK:AB. In column BV i need first number, which formula will find from left side and in column BW i want other formula, which make the same but from right side. The next hard thing is, that i want not search in each column, but only in each third column. Exactly it means from column K then N, Q, T, W and Z.
Result will be when i copy the formula for whole column, in BV will first number from left sied and in BW i will have first number from right side. Left side means, that formula start search from K and right side start search from AB.

I tried it with hlookup, but it search also in every column :(.
Pls. any suggestions?
thx for any help.

danovkos
07-08-2015, 05:41 AM
Hi, finaly i maked it with macro.
This workes for me.



Sub PrvaAposlednaAng()

Dim Riadok As Long
Dim I As Integer
Dim Okno As String
Dim List As String
Dim K As Long
Dim a As Integer
Dim L As Long

Okno = ActiveWindow.Caption
List = ActiveSheet.Name


On Error GoTo Exits
Application.EnableEvents = False
Application.Calculation = xlManual
Application.MaxChange = 0.001
Application.ScreenUpdating = False
'
Workbooks(Okno).Sheets(List).Range("BY3").Select

Do Until ActiveCell.Row > 10000
ActiveCell.Offset(1, 0).Select
'z ľava

For K = -48 To -66 Step -3
If ActiveCell.Offset(0, K).Value <> "" Then
ActiveCell.Value = ActiveCell.Offset(0, K).Value
ActiveCell.Offset(0, 1).Value = Cells(2, ActiveCell.Offset(0, K).Column).Value
' ActiveCell.Offset(1, 0).Select
End If
Next K


For L = -66 To -48 Step 3
If ActiveCell.Offset(0, L).Value <> "" Then
ActiveCell.Offset(0, 2).Value = ActiveCell.Offset(0, L).Value
ActiveCell.Offset(0, 3).Value = Cells(2, ActiveCell.Offset(0, L).Column).Value
If L = -45 And ActiveCell.Offset(0, L).Value = "" Then ActiveCell.Offset(0, 4).Value = "jun blank"
End If
If L = -48 And ActiveCell.Offset(0, L).Value = "" Then ActiveCell.Offset(0, 4).Value = "jun blank"
Next L
Loop

MsgBox "done"

Exits:
Application.EnableEvents = True
Application.Calculation = xlAutomatic
Application.MaxChange = 0.001
Application.ScreenUpdating = True


Riadok = 0
L = 0
I = 0
End Sub