Autofill with VBA

elmnas

Board Regular
Joined
Feb 20, 2015
Messages
206
Hello guys

This is my excel file its at least 1000 rows.

VPUi9EP.png



The textcontent in Column T example in this case "12" or "10" tells how many instances there is of same number in column A.
I need now to autofil the the 12 and 10 so I get this result see picture:

1SF7SBk.png


Could someone help me with a code?




Thank you in advance
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Assuming Column T contains constants (not formulas), then give this macro a try...
Code:
Sub FillColumnT()
  Dim R As Long, Cell As Range, ColA As String
  For Each Cell In Columns("T").SpecialCells(xlConstants)
    For R = Cell.Row To 1 Step -1
      If Cells(R, "A").Value = Cell.Offset(, -19).Value Then
        Cells(R, "T").Value = Cell.Value
      Else
        Exit For
      End If
    Next
  Next
End Sub
 
Upvote 0
The code doesnt take all numbers why?
the best should be really if the code checks first after text content IND in column J and has the same value in K same row
then do the stuff

here is another function I got

Code:
Sub CheckMatch()



' the code look in column J after a equal Value but in Column K and if found
' Set interior color index = yellow
' select Cell in Column B same row, - 1 then divide by sum from column AB then present a new result in Column T same row
For i = 2 To ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
    If Cells(i, "J") = Cells(i, "K") And Len(Cells(i, "B")) <> 0 And Cells(i, "AB") <> 0 Then
       


'Dim DivAB As String


'Rows(i).Select


Cells(i, 1).EntireRow.Interior.ColorIndex = 6
'Cells(i, "B").Select
myCell = Cells(i, "B").Text
mycellRes = myCell
DivAB = Cells(i, "AB").Text


myTot = Round(DivAB / mycellRes)
 ' presentera i kolumn T


'mycellSel = Cells(i, "T").Select
'ActiveCell.Value = myTot
Cells(i, 20) = myTot




'MsgBox myTot




    End If
Next i




End Sub
 
Last edited:
Upvote 0
Without words, that picture tells me nothing. As I understood your question, you were putting a number in Column T at the bottom of a range of identical cell values in Column A and you wanted that value in Column T copied up for all the matching numbers in Column A. That is what your first picture showed and that is what my code does. Now, it that is not doing what you want, then tell us what it is that you actually need.
 
Upvote 0
Is it possible for you to modify the code
so the script look first Column J and then column K as the script I sent you?
then if the text content in each cell on same row are same, then take the text content (34181) from same row but Column A, then find in column A first instance of the number?
auto fil BAM

Thank you in advance
 
Upvote 0

Forum statistics

Threads
1,215,011
Messages
6,122,680
Members
449,091
Latest member
peppernaut

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