2016-04-01 11 views
0

example dataEş durumlarda i colums MS Excel

I dört veri sütunu, bu iki isimler (A ve D) sahip bir fark bulunamamıştır. Bir (B) toplam çalışma saatidir ve bir (E) eğitim zamanıdır. Arka arkaya 5. sıradaki "32.8" ve "24.6", 2. dizide sağ yerde C sütununda sütun E değeri yazar, yani "41":

Bunu yapan bir işlev yazabilir 8.

Teşekkürler.

cevap

0

ben sadece hızlı birlikte bir şeyler koymak, ama .... sen vb sac adını kullanacak şekilde değişiklikler yapmanızı gerektirecek, bu Paul S yardımcı

Private Sub FindNames() 
Dim RngArr As Variant 
Dim i As Long, j As Long 
Dim Rws As Long 
Dim FRw As Long 

'Sheet1 here is not the tab name, but the CodeName (in VBA its the name not in brackets in project explorer) 
RngArr = Sheet1.UsedRange.Value 'get range array 

If Not IsArray(RngArr) Then Exit Sub 'either a single cell is used or something is wrong 

FRw = Sheet1.UsedRange.Row 
Rws = UBound(RngArr, 1) - 1   'get total rows in range minus 1 

For i = FRw To FRw + Rws  'loop for the list in D:E 
    If Not RngArr(i, 4) = vbnulstring Then 
     For j = FRw To FRw + Rws 'loop for the list in A:B (C) 
      'if ColD = ColA then ColC = ColE 
      If RngArr(i, 4) = RngArr(j, 1) Then RngArr(j, 3) = RngArr(i, 5) 
     Next j 
    Else 
     'you could exit the loop here if you list will never have empty spaces to save time although you wont notice 
    End If 
Next i 

Sheet1.UsedRange.Value = RngArr 'since we are resizing the original used space we can just dump the results back 

End Sub

Umut işleri

İlgili konular