Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I'm looking for a vba macro that copy whole data inside a sheet to another creating the new sheet. For example; I have a sheet called 14.11.2013 with some values.. clicking a button i need that the macro creates the new sheet and copy the entire datas from 14.11.2013 sheet to this one new. I'm a beginner in vba so i don't have much idea how can i do this kind of work. Someone can help me?
Of course when everything is copyed i want redirect in the new sheet.. I think something like:
Sheets("NewSheet").Activate
Here is the general format:
Sub CopySheet()
Dim s As Worksheet
Set s = Sheets("14.11.2013")
s.Copy after:=s
End Sub
If you are looking for some beginner tutorials i would recommend ExcelVBAIsFun on youtube.
I believe this video will help with how to record macros and teach yourself how to do some of the more simple things in Excel VBA. It also does something very similar to copying from one sheet to the other.
http://www.youtube.com/watch?v=HmAYKyurYNU&list=PLw8O1w0Hv2ztGjIkrW7suD6oNDaOk3vbR
I used this quite a bit while learning VBA myself.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I don't know where to start with this. If there is a way, all I need is an object name or collection name, so I can look up the feature on Microsoft's site, and go from there. But, searching there directly didn't turn anything up.
You're probably looking for the VBE Extensibility Library.
However note that depending on what you're actually trying to do ("modify other VBA code"), it may be very hard, if not impossible to implement.
The library will let you iterate modules, locate their members, pull the actual code into strings (from entire modules or just a given procedure)... but that's as granular as it gets.
If you're trying to do anything that requires understanding of the code's semantics, the VBIDE API won't be enough: you need a lexer and a parser for that... and I've yet to see a successful lexer/parser for VBA, written in VBA.
Good luck!
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a spreadsheet that I'm using as a template to get user input. When you press the submit button on the spreadsheet, it sends the data to a different workbook that stores all the previous entries and then clears the template. Is there a way to save the template as a different file when you push the button? I know about .Saveas(), but I want a file name that's based off what was typed in cell A2 and B2?
I do this on a daily basis saving the file as the previous days date. I modified what I use for what you are wanting:
dim name as string
name = Cells(1,2).Value & Cells(2,2).Value
ActiveWorkbook.SaveAs() Filename:=name
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
is there a way to count how many times a text appear on a worksheet?
im sorry about my question but I don't know how to start.
thanks.
the short answer is "Yes"
Here are a few ways:
in cell A1 put the following formula:
=COUNTIF(2:1048576,"here") + COUNTIF(B1:XFD1,"here")
this will count the number of times "here" appears on the worksheet
if you'd like to use vba, this should return the expected result:
Sub test()
Dim wordCount As Long
wordCount = Application.WorksheetFunction.CountIf(ActiveSheet.Cells, "here")
End Sub
I'm sure there are a handful of other ways to go about it, but hopefully this will get you started.
The longer answer is (as mentioned in the comments): Please be a bit more descriptive in your ask so someone can tailor an answer to fit your specific requirements. That, or google it.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
This may seem to be a very simple question for a number of Excel users out there. Yes, I admit I am ignorant about this.
The question is quite simple.
How do I prevent manual re-sizing of a cell in Excel? In other words the user should not be able to change either the width or height of a cell / range of cells
Is this done through writing VBA code? Or can it be carried out in any other way using standard Excel menu based commands?
Thanks in advance
Romi
You will need to 'Protect' the sheet
There are two steps:
Make sure the cells are locked
Protect the sheet
In Excel 2010
Select the cells you want to prevent from being resized.
Click on the Home tab and click to expand the Font section
Select the Protection tab and make sure that the Locked box is ticked
Click on the Review tab and then Protect sheet
Click on the OK button
You can lock the spreadsheet. That would prevent the user from resizing the Columns or the Rows.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have written
sub main ()
'some code goes here
end sub
This is the Module that I defined in the sheet1.And Yes I have only one workbook opened and in the userform1 I have given a command button Ok and when ok is pressed , The main function in sheet1 should be called
sub CommandButton1_Click()
call sheet1.main
end sub
I have tried these The problem Iam facing is , The code works sometimes and sometimes throws an error saying that an undefined object or not set with Occured.Why the code is working for sometimes and not for sometimes? Do i need to make any changes to make it work everytime ? Thank you in advance
The one thing I've found that makes my VBA programming easier is to always fully specify the object you're trying to manipulate (well, except maybe the top-level Application).
That means you should use something like Workbooks(0).Worksheets("Sheet1").main instead of relying on the active workbook.