Excel Functions in VBA

dgrimm

Board Regular
Joined
Sep 17, 2007
Messages
159
Hello All -

I am in need of help (as usual) with some VBA coding. I couldn't find a good example to help me so here I am.

1) I am working on sheet 3 cell E3 and I need to grab a value from sheet 1, whose name will be changing all the time. The value that I am trying to grab is in cell B2.

2) I need to do vlookups on sheet 3, while looking in a completely different file. Let's say C/My Document/Dummy_File and the information is contained on sheet 1 A1:R50.

3) Lastly I need to put text into certain cells but I believe I know how to do this, please correct if I am wrong.

Range("A1").select
ActiveCell.value = "Hello"
with select.font
.name = "Arial"
.size = 16
.bold = true
end with
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
no response yet?
perhaps cue to the mix of questions?

I do not like to mix anyway, so here goes the first one.
Do you mean you want to put the contents of a cell into another?
Code:
Sheets("Sheet3").Range("E3") = Sheets("Sheet1").Range("B2")

wait a moment
whose name will be changing all the time
do you mean the sheetname will not be constant?
then use the index
Sheets(1)
instead of the name itself


see this thread about worksheets stuffhttp://www.mrexcel.com/board2/viewtopic.php?p=1243852


kind regards,
Erik
 
Upvote 0
Re 3, it is inefficient and usually unnecessary to select cells to work with them and you should specify with sheet you are working with:
Code:
With Sheets(1).Range("A1")
    .value = "Hello"
    with .font
        .name = "Arial"
        .size = 16
        .bold = true
    end with
End With
 
Upvote 0

Forum statistics

Threads
1,214,615
Messages
6,120,538
Members
448,970
Latest member
kennimack

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top