0% found this document useful (0 votes)
93 views2 pages

XX Macro Copy-Paste

This document contains instructions for selecting and copying ranges of cells in Excel worksheets using VBA. It includes examples of selecting entire sheets, rows, columns, ranges of cells, individual cells, and using the .Select, .Copy, and .PasteSpecial methods. It also provides examples of copying values and formats between worksheets in the same and different workbooks, opening and closing workbooks, and adding page breaks.

Uploaded by

Jovic Srdjan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views2 pages

XX Macro Copy-Paste

This document contains instructions for selecting and copying ranges of cells in Excel worksheets using VBA. It includes examples of selecting entire sheets, rows, columns, ranges of cells, individual cells, and using the .Select, .Copy, and .PasteSpecial methods. It also provides examples of copying values and formats between worksheets in the same and different workbooks, opening and closing workbooks, and adding page breaks.

Uploaded by

Jovic Srdjan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Selektovanje cele stranice

Sheets("Sheet1").Select
________________________________
Selektovanje redova
Rows("4:6").Select
________________________________
Selektovanje kolona
Columns("C:E").Select
________________________________
Selektovanje polja
Range("A2:D6").Select
________________________________
Dolazak na polje
Range("A1").Select
________________________________
Paste na aktivnoj stranici
ActiveSheet.Paste
________________________________
Paste specijal - Cetka
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False

Ako treba da napise vrednosti iz kolona u redovi i obrnuto


Transpose:=True
________________________________
Selektovanje i Paste specijal - Cetka
Range("A6").Select
Selection.Copy
Range("F6").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
________________________________

Dolazak na poslednje polje u redu


Range("a1").End(xlDown).Offset(1, 0).Select
ili posle (xlDown)
ActiveCell.Offset(1, 0).Select
________________________________
Dolazak na poslednje polje u koloni
Selection.End(xlToRight).Offset(0, 1).Select
ili posle (xlToRight)
ActiveCell.Offset(0, 1).Select
________________________________
'Kopiranje VREDNOSTI I FORMATA
Sheets("Sheet2").Select
Rows("2:13").Select
Selection.Copy
Sheets("Sheet3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A1").Select
________________________________
'Kopiranje iz jednog fajla u drugi - oba moraju da budu otvorena - jedan red
Workbooks("New1.xls").Worksheets("Export").Range("A2:D9").Copy _
Workbooks("New2.xls").Worksheets("Data").Range("A2")
________________________________
'Kopiranje iz jednog fajla u drugi - oba moraju da budu otvorena - dva reda
'Kopiranje na klipboard
Workbooks("New Data.xls").Worksheets("Export").Range("A2:D9").Copy
'PasteSpecial to paste values, formulas, formats, etc.
Workbooks("Reports.xls").Worksheets("Data").Range("A2").PasteSpecial
Paste:=xlPasteValues
________________________________
'Otvaranje i zatvaranje fajla

'Open method requires full file path to be referenced.


Workbooks.Open "C:\Users\username\Documents\New Data.xls"
'Close a workbook
Workbooks("New Data.xlsx").Close SaveChanges:=True
________________________________
'Page Breaks
Range("A12").Select
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
______________________________________________________________________________
This would be true for finding the end also.......
range("a2").end(xldown).select
the line above will put you at the end of the data, the last one with a value
if you want the next one, which should be blank
range("a2").end(xldown).select
activecell.offset(1,0).select
ili
You can use a similar method, which starts from the bottom and first the first cell
with data:
Range("A65536").End(xlUp).Select
To select the first blank cell after your last row of data, use:
Range("A65536").End(xlUp).Offset(1,0).Select

You might also like