excel - VBA Form Completion across multiple worksheets -


i have standard template i've designed in wkbk 1 using grade teachers.wkbk 1 has 15 different worksheets, or 1 per teacher. in wkbk 2, have table using keep scores on different functions. i'm using macro (or attempting to) extract data in wkbk 2 , dump in wkbk 1. when attempt loop macro throughout worksheets, macro pulling teacher 1 , assigning scores teachers 2-15.

sub scorecard()      dim current worksheet      each current in worksheets      range("teacherytd") = "='[teacher formula.xlsx]sheet1'!r3c2"     range("b7:c7").select     range("teachercco") = "='[teacherformula.xlsx]sheet1'!r3c3"     range("f6").select      next  end sub 

i using 'define' point 1 cell across workbooks. not sure if preferred way, direct beginner vba programmer.

can me figure out how "step" next row gather proper teacher's scores?

try below. it's rough , untested, you'll find helpful.

option explicit  sub test()  dim wb1 workbook dim wb2 workbook dim ws worksheet dim ws2 worksheet dim teachers range dim teacher range  'using objects makes easier maintain code. set wb1 = workbooks("wkbk 1") set wb2 = workbooks("wkbk 2") set ws2 = wb2.sheets("yourtablesheet") '<~~ sheet contains table. set teachers = ws2.range("a2:a17") '<~~list of teachers on table.  'loop through list of teachers. each teacher in teachers     'i'm assuming template sheets named same teachers.     'if (the sheet names , names in list) aren't same,      'this code won't work.     set ws = wb1.sheets(teacher)     'this you'll transfer data. see examples. can add many needed.     'this assumes every template sheet set same.     ws.range("teacherytd") = ws2.range("b" & teacher.row).value '<~~ copies/pastes table data in column b particular teacher teacher's template sheet.     ws.range("teachercco") = ws2.range("c" & teacher.row).value '<~~ same above except column c.     'if have additional data transfer, model additional lines after above 2 lines. next teacher  end sub 

hope helps!


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -