Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Excel ectraction row by row
#1
Hi there

I'm looking for a macro which extracts the contents of a row from A to W and splits the content in different strings, next time i run the macro is run the next row should be extracted the same way. can this be done?

thx in advance

Freggel
#2
Macro Macro1456
Code:
Copy      Help
;/exe 1
ARRAY(str) a
ExcelSheet es.Init

;get selected row index. If selected single column, select A-W.
int r nc
es.GetSelectedRange(0 nc r)
if(nc=1) es.SelectRange(F"A{r}:W{r}")

;get data from selection
es.GetCells(a "sel")

;select next row
r+1
es.SelectRange(F"A{r}:W{r}")


;results
int i
for i 0 a.len(1)
,out a[i 0]
;A in a[0 0], B in a[1 0], C in a[2 0], ...
#3
thank you helped me alot!

if i may can you help me with another thing? is it possible to give the rows which were extracted a colour? so if a certain area has been done this is marked for example green.

Thanks in advance!
#4
insert after es.GetCells...

Code:
Copy      Help
;make selected cells green
Excel.Range sr=es.ws.Application.Selection
sr.Interior.ColorIndex = 4
sr.Interior.Pattern = Excel.xlSolid

or

Macro Excel get row
Code:
Copy      Help
Acc ac=acc("Fill Color" "DROPLIST" win("" "XLMAIN") "MsoCommandBar" "" 0x1001)
ac.Mouse(1)

The second code does not erase Undo.
#5
Thank you very much!

can you tell me also how i can paste content in a cell in the row i just colored?

like from a listbox with 3 options in like the 'W' cell ?

Sorry for bothering you so much but thanks for helping me out!
#6
es.SetCell("content" 23 r) ;;23 is for W column
#7
Hello,

Can someone tell me why this :

sel(list(items "" "test" 800 500 0 0 0x3))
case 1 es3.SetCell("Done" 24 r3)

doesn't work ?

and this:

sel list(items "test")
case 1 es3.SetCell("Done" 24 r3)

Does?

All I want is to place this listbox on a certain area on the screen and have it active, it is placed and active but in the first sample it does not place the 'done' in the excel-cell and in the 2nd sample it does.

I cannot figure out what is wrong...
#8
If you use flag 2 with LIST, items must contain numbers.

Macro Macro1423
Code:
Copy      Help
str items="1 a[]2 b"
sel(list(items "" "test" 800 500 0 0 0x3))
,case 1 mes 1

or don't use flag 2

Macro Macro1423
Code:
Copy      Help
str items="a[]b"
sel(list(items "" "test" 800 500 0 0 0x1))
,case 1 mes 1
#9
Thank you very much!


Forum Jump:


Users browsing this thread: 1 Guest(s)