PDA

View Full Version : Insertion range depends on meeting conditions



Bline
12-18-2022, 02:06 PM
HI. team . i need your help please . i wont to start my insert colums from B3 and the range of my insert depends on how many cells meet my condition. How could I do this, any ideas?303973039830399

rollis13
12-18-2022, 02:52 PM
Use this instead:
If Worksheets("LEER").Range("A" & i).Text = Range("A1").Text Then
Range("B" & Range("B201").End(xlUp).Row + 1).Value = Worksheets("LEER").Range("B" & i).Value
End If

Bob Phillips
12-19-2022, 12:31 PM
Try this


Sub UpDate()
Dim liste As Worksheet
Dim targetrow As Long
Dim lastrow As Long
Dim i As Long

Set liste = Worksheets("Liste")

With Worksheets("LEER")

targetrow = 3

lastrow = Cells(.rows.Count, "A").End(xlUp).Row
For i = 1 To lastrow

If .Cells(i, "A").Value = liste.Range("a1") Then

liste.Cells(targetrow, "A") = targetrow - 2
liste.Cells(targetrow, "B").Value = .Cells(i, "B").Value

targetrow = targetrow + 1
End If
Next i
End With
End Sub

Grade4.2
12-20-2022, 06:02 AM
The below code works only after I change the dates on the "LEER" sheet to actual dates.
Because you're using the date in cell A1 as reference, it needs to be able to identify dates on the Leer sheet.


Sub UpDate()
' Clear contents of the specified range on the "Liste" worksheet
Worksheets("Liste").Range("B3:C250").ClearContents


' Declare and initialize the TargetRow variable
Dim TargetRow As Integer
TargetRow = 3


' Loop through the rows on the "LEER" worksheet
Dim i As Integer
For i = 1 To 250
' Check if the value in column A on the "LEER" worksheet matches the value in A1 on the "Liste" worksheet
If Worksheets("LEER").Range("A" & i).Text = Worksheets("Liste").Range("A1").Text Then
' If the values match, copy the value in column B on the "LEER" worksheet to column B on the "Liste" worksheet
Worksheets("Liste").Range("B" & TargetRow).Value = Worksheets("LEER").Range("B" & i).Value


' Increment the TargetRow variable
TargetRow = TargetRow + 1
End If
Next
End Sub