Insert formula into cells using excel vba -
i'm trying follow this example, it's not working. offset
cause problem?
here's have:
sub parse_dates_flurry() dim col_diff integer ' how many columns away unparsed date col_diff = -20 dim num_of_char integer num_of_char = 10 dim sheet_name_flurry string sheet_name_flurry = "flurry_an_output.csv" ' rows used in sheet dim rows1 long rows1 = get_rows_generic(sheet_name_flurry, 1) ' find last column , fill formula dim formula_parse string formula_parse = "=left(rc[col_dif],num_of_char)" ' dim starting_cell_range range dim n long worksheets(sheet_name_flurry) set starting_cell_range = .range(find_last_column(sheet_name_flurry)) starting_cell_range.offset(0, 1) = "parsed date" n = 1 (rows1 - 1) ' getting error here: starting_cell_range.offset(n, 1).formula = formula_parse next n end end sub
formula_parse = "=left(rc[col_dif],num_of_char)"
should this:
formula_parse = "=left(rc[" & col_dif & "]," & num_of_char & ")"
remember formula_parse
in form of string correct.
concatenate value of variable it, you'll need above.
, since passing formula in r1c1
notation, change line:
starting_cell_range.offset(n, 1).formula = formula_parse
to this:
starting_cell_range.offset(n, 1).formular1c1 = formula_parse
Comments
Post a Comment