I'm new in VBA excel, now I require to develop a Marco to search through a table and insert the value to that particular cell. I know there is a technique which to loop through all the column and row, but it create more problems to my code. Any other technique can achieve that?
How can I search for Week 7 and Bread and I want to insert value of 10 in that cell in Marco? Thank you.
Without using a loop you can get the target row and columns by using .Find() to get the row ans column numbers and then Cells (rownumber, columnnumber) to store the data.
The code below should give you a way forward
Sub insert()
Dim myColumn As Range
Dim myRow As Range
Set myColumn = Sheets("Sheet1").Rows("2:2").Find("Week 2")
Set myRow = Sheets("Sheet1").Columns("A:A").Find("Nuts")
Sheets("Sheet1").Cells(myRow.Row, myColumn.Column) = "10"
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.