ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   vb code question (https://www.excelbanter.com/excel-programming/410120-vbulletin-code-question.html)

Stan

vb code question
 
I have numeric data in column A which which I want to find and then copy each
row that contains this data in columns A-C. In other words if rows 6 through
21 contain the value 7760 then through VB code I want to copy the data in
rows 6-21 and columns A-C.
I took a stab at the code below but it's giving me a data mismatch error on
the first part.

I'm new to coding so any help you can provide would be greatly appreciated.
Many thanks!



Sub GetData()
Dim rng As Range
Set rng = Range("A:C").Find(What:=7760, _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
ActiveCell.Select
ActiveCell.Offset(0, 3).Select

Dim LastCellInN As Range
With ActiveSheet
Set LastCellInN = .Cells(.Rows.Count, "N").End(xlUp)
.Range("A3").Formula = "=N3/" & LastCellInN.Address(0, 0)

End With
End Sub



All times are GMT +1. The time now is 02:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com