|
-
Feb 2nd, 2011, 09:11 AM
#1
Thread Starter
Addicted Member
[RESOLVED] copy user entered data to new sheet
Hi,
I tried but didn't find this answer. I need a macro in a cell of Sheet1 to be copied over to Sheet2 as the user enters information. But it doesn't stop there, it also has to convert the information. ie, if the user enters 20, then this must be converted to a string of "medium".
I tried this, but it didn't do anything
wkbSheet2.Range("F" & rowCt).Value = wkbSheet.Range("F" & rowCt).Value
THanks
-
Feb 2nd, 2011, 10:49 AM
#2
Re: copy user entered data to new sheet
How do you set rowCt?
You can use a Select Case statement to change 20 to "medium"
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
-
Feb 2nd, 2011, 11:12 AM
#3
Thread Starter
Addicted Member
Re: copy user entered data to new sheet
sorry, I should've replaced that, it is a row counter, just pretend it is a valid row number
wkbSheet2.Range("F1").Value = wkbSheet.Range("F1").Value
I understand how to use Select Case statements, but was wondering how to put a formula in a cell.
Besides, what I have here doesn't set the cell to a macro for when the user enters a value??
-
Feb 2nd, 2011, 12:07 PM
#4
Re: copy user entered data to new sheet
To put a formula in a cell prefix it with =
I did a search on excel assign macro to a cell and that was the first choice.
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
-
Feb 2nd, 2011, 02:13 PM
#5
Thread Starter
Addicted Member
Re: copy user entered data to new sheet
Groovy, this is getting somewhere, but I should've elaborated. I am creating this excel file from VB.net, so I need to have this embedded in the sheet while creating it. hhmmmmmm??
Now what?
-
Feb 2nd, 2011, 02:17 PM
#6
Re: copy user entered data to new sheet
You can record a macro in excel. That will give you an idea on how to do it in .NET.
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
-
Feb 2nd, 2011, 04:16 PM
#7
Thread Starter
Addicted Member
Re: copy user entered data to new sheet
I know how to put a macro in Excel while in Excel. AND I know how to create the Excel file from VB.Net, What I need to know is how to Programmatically create the Excel file while adding/embedding macros/WithEvents in the worksheet.
This will then allow the user with the finished Excel file to enter data, which the WithEvent macro will massage and put into another cell.
-
Feb 3rd, 2011, 02:55 AM
#8
Re: copy user entered data to new sheet
when you say macro in cell, do you mean formula?
if so try like
vb Code:
range("A1").formula = sht2.range("b6").formula
if not, please elaborate on what you wish to achieve
see the tutorial for automating office applications in the faq thread at the top of this forum
Last edited by westconn1; Feb 3rd, 2011 at 05:48 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Feb 3rd, 2011, 03:12 PM
#9
Thread Starter
Addicted Member
Re: copy user entered data to new sheet
Thanks for your reply, and you are right it is a formula I want, got my apples mixed with my oranges.
I could not find the tutorial you mentioned.
I tried your example and it did nothing for me, this is a version I tried with no luck either...
wkbSheet2.Range("G7" ).Formula = "= " & wkbSheet.Range("G7").Formula
also
wkbSheet2.Range("G7" ).Formula = "= " & wkbSheet.Range("G7").value
neither did anything.
The final result I really need is when the user enters a number, then a calculation is done on it and a text value is put in the other sheet. ie user enters 25, then "Low" is put in the next sheet, value of 75,then "High".
Any help is appreciated, I have been struggling for 2 days.
-
Feb 3rd, 2011, 03:55 PM
#10
Thread Starter
Addicted Member
Re: copy user entered data to new sheet
me again, still plugging at this. I can do this by hand in Excel!!!
my latest effort.
Dim formula As String
formula = " =focus!F" & rowCt
wkbSheet2.Range("F" & rowCt).Formula = formula
where "focus" is the name of the sheet I want to copy info FROM to wkbsheet2 as it is entered by user.
all this does is put the text value of the formula into each cell.
???
-
Feb 3rd, 2011, 04:03 PM
#11
Re: copy user entered data to new sheet
DebbieInFlorida, you need to use the worksheet change event to achieve what you want.
Do you have a sample file?
Sid
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 3rd, 2011, 04:37 PM
#12
Thread Starter
Addicted Member
Re: copy user entered data to new sheet
Thanks SID, but you are wrong!! I just figured it out myself, I am so happy I am going out for a beer after this entry.
this is the magic answer..
dim formula as string
formula = "=" & sSheetName & "!G" & rowCt ' ' this works
wkbSheet2.Range("G" & rowCt).Formula = formula
'== sheetname is the name that I set the first sheet to.
YippEE!!
-
Feb 3rd, 2011, 05:09 PM
#13
Re: [RESOLVED] copy user entered data to new sheet
Thanks SID, but you are wrong!!
Are you sure? 
Sid
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|