excel - VBA - Count Rows then in Column C then fill Columns A, B and P with Equations -
i have 5 columns. column c "account" , column d "person" data set.
i want use vba @ how many rows of data have , fill number of rows in 1) column e "concatenate" concatenate of "account" , "employee" fill number of rows in 2) columns , b index-match equation have.
..i tried draw out columns below isn't formatting in way i'd be... sorry
owner | comment | account | employee | concatenate jay | done | jsma1 | sally | jsma1 sally | not done| kllm4 | jack | kllm4 jack ken | done | bm3r1 | sam | bm3r1 sam any ideas?
try this:
option explicit public sub fillranges() dim ur range, hdr range, concol variant, lrow long dim owncol variant, comcol variant dim actcol variant, empcol variant set ur = sheet1.usedrange ' minimal range set hdr = ur.rows(1) ' header row lrow = ur.rows.count ' last row application owncol = .match("owner", hdr, 0) comcol = .match("comment", hdr, 0) actcol = .match("account", hdr, 0) empcol = .match("employee", hdr, 0) concol = .match("concatenate", hdr, 0) end if not iserror(owncol) , _ not iserror(comcol) , _ not iserror(actcol) , _ not iserror(empcol) , _ not iserror(concol) _ ur .range(.cells(2, owncol), .cells(lrow, owncol)) = "index-match equation 1" .range(.cells(2, comcol), .cells(lrow, comcol)) = "index-match equation 2" .range(.cells(2, concol), .cells(lrow, concol)).formula = _ "=indirect(address(row()," & actcol & ")) & "" "" & " & _ " indirect(address(row(), " & empcol & "))" end end if end sub
Comments
Post a Comment