excel vba - Type mismatch error in vba using activecell -


i getting error type mismatch.. trying set active cell equal cell. if activecell = e4:e18 here code can tell me i'm doing wrong in here.

        if activecell.row = range(cells(4, 5), cells(18, 5))               activesheet.cells(activecell.row, 4) =         if activecell.row = range(cells(4, 8), cells(18, 8))               activesheet.cells(activecell.row, 7) = 

which i'm trying set active cell = e4 e18 '

you trying compare number activecell.row against range object range method returns. need use this:

if activecell.row = range(cells(4, 5), cells(18, 5)).row 

however, not work how want to. activecell ever single cell, row property single number. selection range can more single cell. however, row property still returns row number first row of cells.

if trying check if activecell within range e4:e18, use intersect method see if returns range object:

if not (intersect(activecell, range(cells(4, 5), cells(18, 5))) nothing)     msgbox "yes" else     msgbox "no" end if 

if concerned row number, use

if (activecell.row >= 4 , activecell.row <= 18)     msgbox "yes" else     msgbox "no" end if 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -