Excel VBA to copy -


my task create searchable database within excel entry form. need macro take data entry form move database sheet offset active cell down 1 row , copy values only(not formatting)

every time try run macro run-time error in code. have no experience vb or vba; please tell me wrong this.

sheets("database").select       'navigates database worksheet if activesheet.filtermode     activesheet.showalldata end if                          'clears filters sheets("entry form").select     'navigates entry form worksheet  range("e10:l10").select           ' select date, period, , data selection.copy sheets("datatable").select      ' navigate datatable tab range("a1").select selection.end(xldown).select    ' ctrl-down last occupied row, activecell.offset(1, 0).select  ' 1 more first blank row  selection.pastespecial paste:=xlpastevalues 'pastes data values database worksheet  sheets("entry form").select     'navigates entry form worksheet application.cutcopymode = false 'clears copy data clipboard range("e10, l10").select selection.clearcontents         'clears data drop down selections  range("e10").select             'returns selection date entry box 

it goes bottom of next page , gives 1004 error.

you need more column label in a1 if going use xldown. there has @ least 1 more value in column or traverse bottom of worksheet. better bottom of worksheet upwards , offset 1 row down.

with sheets("database")       'primarily use database worksheet     if .filtermode .showalldata     .cells(rows.count, 1).end(xlup).offset(1, 0) 'look bottom down 1 row         'direct value transfer faster copy, paste special, values         .cells.resize(1, 8) = sheets("entry form").range("e10:l10").value     end end  sheets("entry form")     'primarily use entry form worksheet     .range("e10:l10").clearcontents 'clears data drop down selections     .range("e10").select            'returns selection date entry box end 

this makes use of with ... end statement control worksheet receiving attention. see how avoid using select in excel vba macros more methods on getting away relying on select , activate accomplish goals.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -