VBA excel macro that iterates a table and select all rows which row cell at column A equals something -


i'm trying iterate table , index rows cell (cell date) @ position (column a) equals date date cell lets h1 cell. have button attached macro on when clicked. table has more 10000 rows , have 7 columns ( a, b, c, d, e, f, g) column represents date. in javascript somthing this.

all cells inside column have day/month/year values. , whole table year only. table starts 01/01/2017 , end @ 31/12/2017.

const mydate = worksheet.getcell('h1').value; const columna = worksheet.getcolumns('a') // here use pseudocode  columna.foreach((cell, index) => {     if (cell.value == mydate)       console.log(index); // instead can push each index in array later foreach rows these indexes , manipulation. }); 

my task put date string h1 cell. , when button clicked rows first cell ( column ) equals h1 cell must printed.

edited:

tried far , i'm storing , indexes day starts , ends. have range. how can select cells rows between firstrow , lastrow , print them out.

sub findmynubmer()     dim range, b range     dim firstrow long     dim lastrow long     set = range("a1:a65000")      each b in a.rows         if b.value = range("h4").value             if firstrow = "0"                 firstrow = b.row             end if             lastrow = b.row         end if     next     msgbox firstrow & " - " & lastrow end sub 

try autofilter; used cells h4 , h5 on sheet1 show example of date range criteria


option explicit  public sub markdates()     dim ws worksheet, cola range, lc long, hdr long      set ws = sheet1     set cola = ws.usedrange.columns(1)     lc = ws.usedrange.columns.count + 1     'today's date in last col      application.screenupdating = false      cola          .autofilter field:=1, _                     criteria1:=">=" & cdbl(ws.range("h4")), _                     operator:=xland, _                     criteria2:="<=" & cdbl(ws.range("h5"))          if .specialcells(xlcelltypevisible).countlarge > 1             hdr = abs(not isdate(.cells(1)))             ws.usedrange.columns(lc)                 .offset(hdr).resize(.rows.count - hdr, 1) = date    'last used column                 .numberformat = cola.numberformat             end         end if          .autofilter      end      application.screenupdating = true  end sub 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -