i select rows print table 7 columns. use printout
method print them out.
is there elegant way add 3 variables values @ top of paper before selected rows?
i can set cells values of these variables , on next rows paste selected rows table , print newly created table. seems complicated.
here macro:
sub findmynubmer() dim range, b range dim firstrow long dim lastrow long dim eurstart long dim eurend long dim usdstart long dim usdend long dim gbpstart long dim gbpend long set = activesheet.range("a1:a65000") each b in a.rows if activesheet.range("d" & b.row) = "eur" or activesheet.range("d" & b.row) = "eur-" eurstart = eurstart + activesheet.range("g" & b.row) end if if activesheet.range("d" & b.row) = "usd" or activesheet.range("d" & b.row) = "usd-" usdstart = usdstart + activesheet.range("g" & b.row) end if if activesheet.range("d" & b.row) = "gbp" or activesheet.range("d" & b.row) = "gbp-" gbpstart = gbpstart + activesheet.range("g" & b.row) end if if b.value = activesheet.range("h4").value if firstrow = "0" firstrow = b.row end if lastrow = b.row if activesheet.range("d" & b.row) = "eur" or activesheet.range("d" & b.row) = "eur-" eurend = eurend + activesheet.range("g" & b.row) end if if activesheet.range("d" & b.row) = "usd" or activesheet.range("d" & b.row) = "usd-" usdend = usdend + activesheet.range("g" & b.row) end if if activesheet.range("d" & b.row) = "gbp" or activesheet.range("d" & b.row) = "gbp-" gbpend = gbpend + activesheet.range("g" & b.row) end if end if next eurend = eurstart - eurend usdend = usdstart - usdend gbpend = gbpstart - gbpend activesheet.range("a" & firstrow & ":g" & lastrow).select msgbox eurstart & " - " & eurend msgbox usdstart & " - " & usdend msgbox gbpstart & " - " & gbpend end sub
if change .select method printout print cells in range expected.
i want put eur / usd / gbp start/end variables on top before printing.
since table has 7 columns print before table cells.
eur eurstart var. eurend var. usd ... ... gbp ... ...
here rewrite of code. not meant answer question.
you have logic errors. code still checks usd , gbp after eur matches.
sub findmynubmer() dim firstrow long, lastrow long dim eurstart long, eurend long dim usdstart long, usdend long dim gbpstart long, gbpend long dim ddd string dim ggg long dim b range each b in activesheet.range("a1:a65000") ddd = b.columns("d") ggg = b.columns("g") select case ddd case "eur", "eur-": eurstart = eurstart + ggg case "usd", "usd-": usdstart = usdstart + ggg case "gbp", "gbp-": gbpstart = gbpstart + ggg end select if b.value = activesheet.range("h4").value if firstrow = 0 firstrow = b.row lastrow = b.row select case ddd case "eur", "eur-": eurend = eurend + ggg case "usd", "usd-": usdend = usdend + ggg case "gbp", "gbp-": gbpend = gbpend + ggg end select end if next eurend = eurstart - eurend usdend = usdstart - usdend gbpend = gbpstart - gbpend activesheet.range("a" & firstrow & ":g" & lastrow).select msgbox "eur" & vbtab & eurstart & " - " & eurend & vbcrlf _ & "usd" & vbtab & usdstart & " - " & usdend & vbcrlf _ & "gbp" & vbtab & gbpstart & " - " & gbpend end sub
Comments
Post a Comment