excel - Invert/reverse columns that don't have a set range using a command button -


i know question has been asked can't seem make find work me.

i want take data starting in column , going column j row 2 whatever end of data might , reverse order(inverse data)

i stumbled upon the code below freezes , don't want have make selection.

private sub commandbutton2_click()      dim vtop variant     dim vend variant     dim istart integer     dim iend integer      application.screenupdating = false     istart = 1     iend = selection.columns.count      while istart < iend         vtop = selection.columns(istart)         vend = selection.columns(iend)         selection.columns(iend) = vtop         selection.columns(istart) = vend         istart = istart + 1         iend = iend - 1     loop     application.screenupdating = true  end sub 

to clear, want make last row first row, , last row first row. continuous block of data. cheers

before after

another version of code - see if works.

private sub commandbutton2_click()  dim v(), long, j long, r range  application.screenupdating = false application.calculation = xlcalculationmanual  range("a1").currentregion     set r = .offset(1).resize(.rows.count - 1) end  redim v(1 r.rows.count, 1 r.columns.count)  = 1 r.rows.count     j = 1 r.columns.count         v(i, j) = r(r.rows.count - + 1, j)     next j next  r = v  application.calculation = xlcalculationautomatic application.screenupdating = true  end sub 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -