Hello,
I’m very new to excel macro's
What I am trying to do is take Info from a BOM with Reference, Value and Part numbers from sheet1 and move the data into sheet2 that I can then use to print a sticker.
when I run my macro it opens a search box, I search for a unique part value then it will copy and paste 3 cells from the same row to a sheet2 A1,A2,A3 and then move them in a way, so I am able to print them to a sticker.
I have found some random bits of code scattered around the web that dose 90% of what I want but I can’t seem the last few bits to work, and I hope someone could help me out.
I would like to remove the formatting when it copies the data, I have tried some of the paste special options, but they never work.
I guess my only other way I could make it work is so it formats sheet when I has finished the copy?
If anyone could point me in the right direction it would really help me out.
Thanks
I’m very new to excel macro's
What I am trying to do is take Info from a BOM with Reference, Value and Part numbers from sheet1 and move the data into sheet2 that I can then use to print a sticker.
when I run my macro it opens a search box, I search for a unique part value then it will copy and paste 3 cells from the same row to a sheet2 A1,A2,A3 and then move them in a way, so I am able to print them to a sticker.
I have found some random bits of code scattered around the web that dose 90% of what I want but I can’t seem the last few bits to work, and I hope someone could help me out.
I would like to remove the formatting when it copies the data, I have tried some of the paste special options, but they never work.
I guess my only other way I could make it work is so it formats sheet when I has finished the copy?
If anyone could point me in the right direction it would really help me out.
Thanks
VBA Code:
Sub customcopy()
Dim strsearch As String
Dim lastline As Integer
Dim tocopy As Integer
ActiveWorkbook.Worksheets("Sheet1").Select
strsearch = CStr(InputBox("enter the string to search for"))
lastline = Range("A65536").End(xlUp).Row
j = 1
For i = 1 To lastline
For Each c In Range("A" & i & ":Z" & i)
If c.Text = strsearch Then
tocopy = 1
End If
Next c
If tocopy = 1 Then
Range(Cells(i, "A"), Cells(i, "C")).Copy Destination:=Sheets("Sheet2").Cells(j, "A")
j = j + 1
End If
tocopy = 0
Next i
ActiveWorkbook.Worksheets("Sheet2").Select
Range("A1").Cut Destination:=Range("B3")
Range("B1").Cut Destination:=Range("B4")
Range("C1").Cut Destination:=Range("B5")
End Sub