简体   繁体   中英

Using VBA to select a cell with text in it

How do I select a cell with "Part # 1" in it, and then use that cell as one of the parameters to select a range of cells. For example: If "Part # 1" was in cell A1, I want to select a range of cells A1:D4.

Sub Part_1_Select

'Seach for Cell somehow'
Cell.Activate
ActiveCell: D4.Select
Selection.Copy
Range("B4").Select
Selection.Paste
End Sub

This is what I'm thinking it should be similar too.

For Each c In Worksheets("Sheet1").Range("A1:D10").Cells
    If c.Value = "Part # 1" Then
       Cell.Activate
       Range(c & ":D4").Select
    End If
Next

This isn't perfect code but it may provide you with a good starting point to get where you want.

    Range(Cells.Find(What:="Part # 1").Address & ":D4").Select

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM