简体   繁体   中英

excel vba dynamic values with blank cells

i am new to vba, i need to take two values in a worksheet.Example below:

B10=Date........N10=: ...... P10=Feb-15....

the range of B10 have the date,N10 have the colon and P10 have date value, C10:O10 have empty cells.

so everytime i have to give

Selection.End(xlToRight).Select.

How to take this value dynamic.

Date : Feb-15 Date : Mar-15 Date : Apr-15 Date : May-15 Date : Jun-15 Date : Jul-15 Date : Aug-15 Date : Sep-15 Date : Oct-15 Date : Nov-15 Date : Dec-15

Anyone please help.

Excel Macros = "bad code", they always use "selection" object and .Select method when they're not needed...

I can't really tell what you're trying to do, but if it's simply to concatenate those three cells, you can use something like:

for i = 1 to intLastRow
    with wsWorksheet
        .cells(i,1) = .cells(i,2) & .cells(i, 13) & .cells(i, 15)
    end with
next

But I don't really get the question. Why not just have a formula in a column ="Date: " & text(P10, "mmm-dd")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM