excel - Copy cell values to different Workbook -


firstly, let me apologise if question has been answered somewhere else. had couldn't find me.

secondly, i'm sure there far more simple way i'm new vba , i'm trying teach myself go along.

ok, have sheet @ end of workbook compiles information previous sheet , want copy values in row 2 workbook have network drive.

i've managed work on same sheet not workbook (without using userform).

it comes error 'invalid qualifier' line cells(emptyrow, 1.value - dateraised.value

here code below,

sub commandbutton1_click()  dim emptyrow long dim dateraised long dim customername string dim siteaddress string dim callreason string dim customerorderno long dim invoiceno long dim covernoteno long dim findings string dim producttype string dim supplier string dim attempts long dim condition string dim dateclosed long dim creditgiven string dim creditvalue long dim issuedays long dim comments string  dateraised = cells(2, "a").value customername = cells(2, "b").value siteaddress = cells(2, "c").value callreason = cells(2, "d").value customerorderno = cells(2, "f").value invoiceno = cells(2, "g").value covernoteno = cells(2, "h").value findings = cells(2, "i").value producttype = cells(2, "j").value supplier = cells(2, "k").value attempts = cells(2, "l").value condition = cells(2, "m").value dateclosed = cells(2, "n").value creditgiven = cells(2, "o").value creditvalue = cells(2, "p").value issuedays = cells(2, "q").value comments = cells(2, "r").value  dim wrkbk workbook dim wrksht worksheet  set wrkbk = workbooks.open("r:\6024 onsite\cover note workflow\database\covernote databse.xlsx") set wrksht = wrkbk.sheets("covernote database") wrksht.activate emptyrow = worksheetfunction.counta(range("a:a")) + 1  cells(emptyrow, 1).value = dateraised.value cells(emptyrow, 2).value = customername.value cells(emptyrow, 3).value = siteaddress.value cells(emptyrow, 4).value = callreason.value cells(emptyrow, 5).value = customerorderno.value cells(emptyrow, 6).value = invoiceno.value cells(emptyrow, 7).value = covernoteno.value cells(emptyrow, 8).value = findings.value cells(emptyrow, 9).value = producttype.value cells(emptyrow, 10).value = supplier.value cells(emptyrow, 11).value = attemps.value cells(emptyrow, 12).value = condition.value cells(emptyrow, 13).value = dateclosed.value cells(emptyrow, 14).value = creditgiven.value cells(emptyrow, 15).value = creditvalue.value cells(emptyrow, 16).value = issuedays.value cells(emptyrow, 17).value = comments.value  wrkbk.close (savechanges = false)  end sub 

if can point me in right direction i'd happy man.

it's because you're attempting treat value types (like string , long) variables if reference type (objects) ones calling value property:

cells(emptyrow, 1).value = dateraised.value 

while can't (unless use user defined types): value type variables can accessed are:

cells(emptyrow, 1).value = dateraised 

but can code follows:

option explicit  sub commandbutton1_click()     dim emptyrow long     dim cursht worksheet      set cursht = activesheet     workbooks.open("r:\6024 onsite\cover note workflow\database\covernote databse.xlsx").sheets("covernote database")         emptyrow = worksheetfunction.counta(.range("a:a")) + 1         .cells(emptyrow, 1).resize(, 17).value = cursht.cells(2, 1).resize(, 17).value '<-- paste values opened sheet range a2:q2     end     activeworkbook.close savechanges:=false end sub 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

python 3.5 - Pyqtgraph string in x tick -