Using VBA, I want to achieve the following:
Select sheet1, then select cell A1 (absolute), then input the text "Hello" in A1.
If you cannot stop laughing, please try to remember the first time you use VBA in Excel.
Thanks!
Using VBA, I want to achieve the following:
Select sheet1, then select cell A1 (absolute), then input the text "Hello" in A1.
If you cannot stop laughing, please try to remember the first time you use VBA in Excel.
Thanks!
All referencing in VB is absolute.
If you want to put "Hello" in Sheet1!A1will do it.![]()
Please Login or Register to view this content.
Selecting is not needed and makes things more difficult. The codewill do what you want, but it will cause an error if Sheet 2 is active![]()
Please Login or Register to view this content.
This avoids that problem, but the first is easier.
![]()
Please Login or Register to view this content.
phuang1226
Please read forum rules, new rules apply since early this year.- see blue link below.
The 1st part of your thread title is invalid.
No question is to trivial.
Whilst the answer may be simple &/or be of general knowledge to people who play around with VBA code, it is knowledge you do not have and require.
It can even be a case that you know a way to do something but you may not know the best way to do it. This will be one reason mikerickson has given a detailed reply & not just given one way of acheiving what you are after.
I have been playing around with VBA code for years & I still come across postings from others that have more efficient code to do something than the code I had been using.
Please Read Forum Rules Before Posting
Wrap VBA code by selecting the code and clicking the # icon or Read This
How To Cross Post politely
Top Excel links for beginners to Experts
If you are pleased with a member's answer then use the Scales icon to rate it
If my reply has assistedor failed to assist you
I welcome your Feedback.
Actually, all referencing in VBA is not absolute. The code below creates a relative reference based on the cell you're in (and using "ActiveCell..." is quite common in VBA).
If your active cell is A1, yes, it will select cells A1 through B2. But, if your active cell is E5, this code won't select A1:B2, it will select E5:F6 (the equivalent of 2 rows x 2 columns).![]()
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks