Some basic VBA Excel scripting questions

%3CLINGO-SUB%20id%3D%22lingo-sub-2744951%22%20slang%3D%22en-US%22%3ESome%20basic%20VBA%20Excel%20scripting%20questions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2744951%22%20slang%3D%22en-US%22%3E%3CP%3EHey%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20like%20to%20copy%20the%20entire%20contents%20of%20one%20Excel%20sheet%20from%20one%20project%20to%20a%20different%20sheet%20in%20a%20different%20project%2C%20using%20VBA%20scripting.%20How%20would%20I%20do%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThen%2C%20I%20would%20like%20to%20copy%20all%20the%20entries%20from%20the%20first%20two%20columns%20which%20are%20both%20non-blank%20(i.e.%2C%20if%20a%20row%20has%20an%20entry%20in%20the%20first%20and%20second%20column%2C%20copy%20both%2C%20but%20if%20either%20column%20is%20blank%2C%20skip%20the%20entire%20row)%20and%20paste%20those%20entries%20to%20a%20second%20sheet.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20might%20I%20do%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2744951%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2745469%22%20slang%3D%22en-US%22%3ERe%3A%20Some%20basic%20VBA%20Excel%20scripting%20questions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2745469%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-visual-basic%22%3E%3CCODE%3ESub%20CopyValuesFromOneSheetToAnotherSheet()%0A%20%20%20%20Worksheets(%22Source%22).Range(%22A1%22).CurrentRegion.Copy%20_%0A%20%20%20%20%20%20%20%20Worksheets(%22Destination%22).Range(%22A1%22)%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1154117%22%20target%3D%22_blank%22%3E%40jukhamil%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Hey,

 

I would like to copy the entire contents of one Excel sheet from one project to a different sheet in a different project, using VBA scripting. How would I do this?

 

Then, I would like to copy all the entries from the first two columns which are both non-blank (i.e., if a row has an entry in the first and second column, copy both, but if either column is blank, skip the entire row) and paste those entries to a second sheet.

 

How might I do this?

 

Thank you.

2 Replies

 

 

Sub CopyValuesFromOneSheetToAnotherSheet()

    With Worksheets("Source").Range("A1").CurrentRegion
        .Offset(1).Resize(.Rows.Count - 1).Copy _
        Worksheets("Destination").Range("A" & Rows.Count).End(xlUp).Offset(1)
    End With
   
End Sub

 

@jukhamil 

@Juliano-Petrukio 

 

See example attached.