ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   offset problems (https://www.excelbanter.com/excel-programming/341371-offset-problems.html)

Pierre via OfficeKB.com[_2_]

offset problems
 
Hi,
I have a button on my userform called "save"

if clicked i would like to save some info on another sheet.

1. The button should look for the first empty cel in column "A" on sheet2
2. it should then put data in A1, B1, C1 etc. This data comes from cells A4,
A5, G5, G6 from sheet1

can anyone please help me with the code that does just this please?
thanks,
Pierre


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200509/1

Dave Peterson

offset problems
 
What kind of button--from the Forms toolbar or from the control toolbox toolbar.

Option Explicit
sub testme() 'forms button
Sub CommandButton1_Click() 'control toolbox toolbar
dim curWks as worksheet
dim savWks as worksheet
dim destcell as range

set curwks = activesheet 'if from the forms toolbar
set curwks = me 'if from control toolbox toolbar
set savwks = worksheets("sheet2")

with savwks
set destcell = .cells(.rows.count,"A").end(xlup).offset(1,0)
end with

with destcell
.value = curwks.range("a4")
.offset(0,1).value = curwks.range("A5").value
.offset(0,2).value = curwks.range("G5").value
.offset(0,3).value = curwks.range("G6").value
end with

end sub

I don't know what etc would mean...


"Pierre via OfficeKB.com" wrote:

Hi,
I have a button on my userform called "save"

if clicked i would like to save some info on another sheet.

1. The button should look for the first empty cel in column "A" on sheet2
2. it should then put data in A1, B1, C1 etc. This data comes from cells A4,
A5, G5, G6 from sheet1

can anyone please help me with the code that does just this please?
thanks,
Pierre

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200509/1


--

Dave Peterson

Pierre via OfficeKB.com[_2_]

offset problems
 
Hi Dave,

you're my hero !

Thanks a lot, it works fine for me.
By the way:
etc. meant etcetera...
and the button was a forms toolbar button

Dave Peterson wrote:
What kind of button--from the Forms toolbar or from the control toolbox toolbar.

Option Explicit
sub testme() 'forms button
Sub CommandButton1_Click() 'control toolbox toolbar
dim curWks as worksheet
dim savWks as worksheet
dim destcell as range

set curwks = activesheet 'if from the forms toolbar
set curwks = me 'if from control toolbox toolbar
set savwks = worksheets("sheet2")

with savwks
set destcell = .cells(.rows.count,"A").end(xlup).offset(1,0)
end with

with destcell
.value = curwks.range("a4")
.offset(0,1).value = curwks.range("A5").value
.offset(0,2).value = curwks.range("G5").value
.offset(0,3).value = curwks.range("G6").value
end with

end sub

I don't know what etc would mean...


Hi,
I have a button on my userform called "save"

[quoted text clipped - 8 lines]
thanks,
Pierre




--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200509/1

Dave Peterson

offset problems
 
I actually knew what etc. meant as a word <vbg. I wasn't sure what you meant
when you used it--"A1, B1, C1 etc."

Did you want to stop at D1 or IV1?

But glad you could make the code do what you want.



"Pierre via OfficeKB.com" wrote:

Hi Dave,

you're my hero !

Thanks a lot, it works fine for me.
By the way:
etc. meant etcetera...
and the button was a forms toolbar button

Dave Peterson wrote:
What kind of button--from the Forms toolbar or from the control toolbox toolbar.

Option Explicit
sub testme() 'forms button
Sub CommandButton1_Click() 'control toolbox toolbar
dim curWks as worksheet
dim savWks as worksheet
dim destcell as range

set curwks = activesheet 'if from the forms toolbar
set curwks = me 'if from control toolbox toolbar
set savwks = worksheets("sheet2")

with savwks
set destcell = .cells(.rows.count,"A").end(xlup).offset(1,0)
end with

with destcell
.value = curwks.range("a4")
.offset(0,1).value = curwks.range("A5").value
.offset(0,2).value = curwks.range("G5").value
.offset(0,3).value = curwks.range("G6").value
end with

end sub

I don't know what etc would mean...


Hi,
I have a button on my userform called "save"

[quoted text clipped - 8 lines]
thanks,
Pierre



--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200509/1


--

Dave Peterson


All times are GMT +1. The time now is 12:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com