1

The question is a little more difficult than the title, just don't know how to ask it.

I have a spread sheet that contains 4 columns (Part Number,Qty,Location and Description), is there a way using vba o some excel function that can copy and paste data depending on the selected cell the idea is this:

I have the 4 columns and I only need the Part Number,Qty and Description and paste it on a different sheet that has some formulas that need that data, but i need to make some type of input since there are many part number. I'm not sure if I'm explaining my self.

Note: I have never programmed in vba nor excel-vba and I'm not familiar with excel at all, just really basic stuff, this is what i came up with by reading some stuff

Private Sub CommandButton1_Click()

    Worksheets("Sheet1").Range("A4:A65").Copy
    Worksheets("Sheet2").Range("A4:A65").PasteSpecial
    Worksheets("Sheet1").Range("D4:D65").Copy
    Worksheets("Sheet2").Range("D4:D65").PasteSpecial
    Worksheets("Sheet1").Range("F4:F65").Copy
    Worksheets("Sheet2").Range("G4:G65").PasteSpecial

    Worksheets("Sheet1").Range("A4:A65").ClearFormats
    Worksheets("Sheet2").Range("A4:A65").ClearFormats

    Worksheets("Sheet2").Range("A4:A65").Font.Size = 10

    Worksheets("Sheet2").Range("D4:D65").Font.Size = 10

End Sub

this just copies and paste everything i just want specific cell-row the user selects If you can provide any help its useful since I'm trying to learn vba using excel.

-Off topic (how to i format my code in forum)

Edit 1 -

 Dim myValue As Variant

    Part = InputBox("Whitch Part", "Buscar")
    With Worksheets("Sheet1").Range("A4:A65")
    Cells.Find(What:=Part, After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate
MoralesJosue
  • 199
  • 1
  • 4
  • 16
  • You can use [INPUTBOX](http://msdn.microsoft.com/en-us/library/office/ff839468%28v=office.15%29.aspx) to accept the input from the user and then use [.FIND](http://www.siddharthrout.com/2011/07/14/find-and-findnext-in-excel-vba/) to search for the row which has that part number and then copy the data across? Give it a try and if you are still stuck then post the code that you tried and we will take it from there? – Siddharth Rout Aug 11 '14 at 22:03
  • I came up with this with no luck (Edit1) @Siddharth Rout, sorry for long reply Im reading about ActiceCell.Row also – MoralesJosue Aug 12 '14 at 00:08

1 Answers1

0

Did you try using Selection?

E.g.

Selection.Copy Destination:=Range("F1")

This will copy the selected region and paste it in F1.

jivko
  • 444
  • 2
  • 17
  • Ive tried it, but dont know how to proceed, because i want for example the user only selects A1 but need to grab and copy the data from A1,A2,A4 the user could select the 3 fields but i want to avoid that by just selecting a cell from column "A" – MoralesJosue Aug 12 '14 at 14:33